1 56 package org.objectstyle.cayenne.access; 57 58 import java.sql.Connection ; 59 import java.sql.PreparedStatement ; 60 61 import org.apache.log4j.Level; 62 import org.objectstyle.cayenne.dba.DbAdapter; 63 import org.objectstyle.cayenne.map.DbEntity; 64 import org.objectstyle.cayenne.map.EntityInheritanceTree; 65 import org.objectstyle.cayenne.map.EntityResolver; 66 import org.objectstyle.cayenne.map.ObjEntity; 67 import org.objectstyle.cayenne.query.Query; 68 69 78 public abstract class QueryTranslator { 79 80 81 protected Query query; 82 83 87 protected Connection connection; 88 89 94 protected QueryEngine engine; 95 96 97 protected DbAdapter adapter; 98 99 104 protected EntityResolver entityResolver; 105 106 111 public abstract PreparedStatement createStatement(Level logLevel) throws Exception ; 112 113 114 public Query getQuery() { 115 return query; 116 } 117 118 public void setQuery(Query query) { 119 this.query = query; 120 } 121 122 127 public Connection getConnection() { 128 return connection; 129 } 130 131 134 public void setConnection(Connection connection) { 135 this.connection = connection; 136 } 137 138 141 public Connection getCon() { 142 return getConnection(); 143 } 144 145 148 public void setCon(Connection con) { 149 setConnection(con); 150 } 151 152 157 public QueryEngine getEngine() { 158 return engine; 159 } 160 161 164 public void setEngine(QueryEngine engine) { 165 this.engine = engine; 166 } 167 168 public DbAdapter getAdapter() { 169 return adapter; 170 } 171 172 public void setAdapter(DbAdapter adapter) { 173 this.adapter = adapter; 174 } 175 176 181 public EntityInheritanceTree getRootInheritanceTree() { 182 return getEntityResolver().lookupInheritanceTree(getRootEntity()); 183 } 184 185 public ObjEntity getRootEntity() { 186 if (query.getRoot() instanceof DbEntity) { 187 return null; 188 } 189 190 return getEntityResolver().lookupObjEntity(query); 191 } 192 193 public DbEntity getRootDbEntity() { 194 return getEntityResolver().lookupDbEntity(query); 195 } 196 197 200 public EntityResolver getEntityResolver() { 201 return entityResolver; 202 } 203 204 207 public void setEntityResolver(EntityResolver entityResolver) { 208 this.entityResolver = entityResolver; 209 } 210 } | Popular Tags |