1 56 package org.objectstyle.cayenne.wocompat; 57 58 import java.util.Map ; 59 60 import org.objectstyle.cayenne.map.ObjEntity; 61 import org.objectstyle.cayenne.query.SQLTemplate; 62 63 71 public class EOSQLQuery extends SQLTemplate { 72 73 protected Map plistMap; 74 75 public EOSQLQuery(ObjEntity root, Map plistMap) { 76 super(root, null, false); 77 this.plistMap = plistMap; 78 initFromPlist(plistMap); 79 } 80 81 protected void initFromPlist(Map plistMap) { 82 83 setResolvingInherited("YES".equalsIgnoreCase((String ) plistMap.get("isDeep"))); 84 setRefreshingObjects("YES".equalsIgnoreCase((String ) plistMap 85 .get("refreshesRefetchedObjects"))); 86 87 Object fetchLimit = plistMap.get("fetchLimit"); 88 if (fetchLimit != null) { 89 try { 90 if (fetchLimit instanceof Number ) { 91 setFetchLimit(((Number ) fetchLimit).intValue()); 92 } 93 else { 94 setFetchLimit(Integer.parseInt(fetchLimit.toString())); 95 } 96 } 97 catch (NumberFormatException nfex) { 98 } 100 } 101 102 Map hints = (Map ) plistMap.get("hints"); 105 if (hints != null && !hints.isEmpty()) { 106 String sqlExpression = (String ) hints.get("EOCustomQueryExpressionHintKey"); 107 if (sqlExpression != null) { 108 setDefaultTemplate(sqlExpression); 109 if (sqlExpression.toUpperCase().indexOf("SELECT") != -1) { 110 setSelecting(true); 111 } 112 } 113 114 } 115 } 116 } | Popular Tags |