1 19 20 package org.apache.cayenne.access; 21 22 import java.sql.Connection ; 23 import java.sql.PreparedStatement ; 24 25 import org.apache.cayenne.dba.DbAdapter; 26 import org.apache.cayenne.map.DbEntity; 27 import org.apache.cayenne.map.EntityInheritanceTree; 28 import org.apache.cayenne.map.EntityResolver; 29 import org.apache.cayenne.map.ObjEntity; 30 import org.apache.cayenne.query.Query; 31 32 41 public abstract class QueryTranslator { 42 43 44 protected Query query; 45 46 50 protected Connection connection; 51 52 53 protected DbAdapter adapter; 54 55 60 protected EntityResolver entityResolver; 61 62 66 public abstract PreparedStatement createStatement() throws Exception ; 67 68 69 public Query getQuery() { 70 return query; 71 } 72 73 public void setQuery(Query query) { 74 this.query = query; 75 } 76 77 82 public Connection getConnection() { 83 return connection; 84 } 85 86 89 public void setConnection(Connection connection) { 90 this.connection = connection; 91 } 92 93 public DbAdapter getAdapter() { 94 return adapter; 95 } 96 97 public void setAdapter(DbAdapter adapter) { 98 this.adapter = adapter; 99 } 100 101 106 public EntityInheritanceTree getRootInheritanceTree() { 107 return getEntityResolver().lookupInheritanceTree(getRootEntity()); 108 } 109 110 public ObjEntity getRootEntity() { 111 return query.getMetaData(getEntityResolver()).getObjEntity(); 112 } 113 114 public DbEntity getRootDbEntity() { 115 return query.getMetaData(getEntityResolver()).getDbEntity(); 116 } 117 118 121 public EntityResolver getEntityResolver() { 122 return entityResolver; 123 } 124 125 128 public void setEntityResolver(EntityResolver entityResolver) { 129 this.entityResolver = entityResolver; 130 } 131 } 132 | Popular Tags |