1 19 20 package org.apache.cayenne.wocompat; 21 22 import java.util.Map ; 23 24 import org.apache.cayenne.map.ObjEntity; 25 import org.apache.cayenne.query.SQLTemplate; 26 27 35 public class EOSQLQuery extends SQLTemplate { 36 37 protected Map plistMap; 38 39 public EOSQLQuery(ObjEntity root, Map plistMap) { 40 super(root, null); 41 this.plistMap = plistMap; 42 initFromPlist(plistMap); 43 } 44 45 protected void initFromPlist(Map plistMap) { 46 47 setResolvingInherited("YES".equalsIgnoreCase((String ) plistMap.get("isDeep"))); 48 setRefreshingObjects("YES".equalsIgnoreCase((String ) plistMap 49 .get("refreshesRefetchedObjects"))); 50 51 Object fetchLimit = plistMap.get("fetchLimit"); 52 if (fetchLimit != null) { 53 try { 54 if (fetchLimit instanceof Number ) { 55 setFetchLimit(((Number ) fetchLimit).intValue()); 56 } 57 else { 58 setFetchLimit(Integer.parseInt(fetchLimit.toString())); 59 } 60 } 61 catch (NumberFormatException nfex) { 62 } 64 } 65 66 Map hints = (Map ) plistMap.get("hints"); 69 if (hints != null && !hints.isEmpty()) { 70 String sqlExpression = (String ) hints.get("EOCustomQueryExpressionHintKey"); 71 if (sqlExpression != null) { 72 setDefaultTemplate(sqlExpression); 73 } 74 } 75 } 76 } 77 | Popular Tags |