1 19 20 21 package org.apache.cayenne.jpa.bridge; 22 23 import java.util.Map ; 24 25 import org.apache.cayenne.jpa.JpaProviderException; 26 import org.apache.cayenne.jpa.map.JpaNamedQuery; 27 import org.apache.cayenne.map.DataMap; 28 import org.apache.cayenne.map.ObjEntity; 29 import org.apache.cayenne.query.IndirectQuery; 30 import org.apache.cayenne.query.ParameterizedQuery; 31 import org.apache.cayenne.query.Query; 32 33 38 public abstract class JpaIndirectQuery extends IndirectQuery implements 39 ParameterizedQuery { 40 41 protected JpaNamedQuery jpaQuery; 42 protected DataMap parentMap; 43 protected ObjEntity parentEntity; 44 protected Map parameters; 45 46 public Query createQuery(Map parameters) { 47 JpaIndirectQuery clone; 48 try { 49 clone = (JpaIndirectQuery) getClass().newInstance(); 50 } 51 catch (Exception e) { 52 throw new JpaProviderException("Error cloning a query", e); 53 } 54 55 clone.setJpaQuery(jpaQuery); 56 clone.setParentEntity(parentEntity); 57 clone.setParentMap(parentMap); 58 clone.parameters = parameters; 59 60 return clone; 61 } 62 63 public JpaNamedQuery getJpaQuery() { 64 return jpaQuery; 65 } 66 67 public void setJpaQuery(JpaNamedQuery query) { 68 this.jpaQuery = query; 69 } 70 71 public ObjEntity getParentEntity() { 72 return parentEntity; 73 } 74 75 public void setParentEntity(ObjEntity parentEntity) { 76 this.parentEntity = parentEntity; 77 } 78 79 public DataMap getParentMap() { 80 return parentMap; 81 } 82 83 public void setParentMap(DataMap parentMap) { 84 this.parentMap = parentMap; 85 } 86 } 87 | Popular Tags |