1 19 20 package org.apache.cayenne.map; 21 22 import java.util.Iterator ; 23 import java.util.Map ; 24 25 import org.apache.cayenne.query.Query; 26 import org.apache.cayenne.query.SQLTemplate; 27 28 34 class SQLTemplateBuilder extends QueryBuilder { 35 36 39 public Query getQuery() { 40 41 SQLTemplate template = new SQLTemplate(); 42 Object root = getRoot(); 43 44 if (root != null) { 45 template.setRoot(root); 46 } 47 48 template.setName(name); 49 template.initWithProperties(properties); 50 51 template.setDefaultTemplate(sql); 53 if (adapterSql != null) { 54 Iterator it = adapterSql.entrySet().iterator(); 55 while (it.hasNext()) { 56 Map.Entry entry = (Map.Entry ) it.next(); 57 Object key = entry.getKey(); 58 Object value = entry.getValue(); 59 if (key != null && value != null) { 60 template.setTemplate(key.toString(), value.toString()); 61 } 62 } 63 } 64 65 return template; 66 } 67 } 68 | Popular Tags |