1 22 package org.jboss.ejb.plugins.cmp.jdbc2; 23 24 import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCEntityBridge2; 25 import org.jboss.ejb.plugins.cmp.jdbc2.bridge.JDBCCMPFieldBridge2; 26 import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCJBossQLQueryMetaData; 27 import org.jboss.ejb.plugins.cmp.jdbc.QLCompiler; 28 import org.jboss.ejb.plugins.cmp.jdbc.EJBQLToSQL92Compiler; 29 import org.jboss.logging.Logger; 30 import org.jboss.deployment.DeploymentException; 31 32 36 public class JBossQLQueryCommand 37 extends AbstractQueryCommand 38 { 39 public JBossQLQueryCommand(JDBCEntityBridge2 entity, JDBCJBossQLQueryMetaData metadata) throws DeploymentException 40 { 41 this.entity = entity; 42 43 JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); 44 QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); 45 46 try 47 { 48 compiler.compileJBossQL( 49 metadata.getJBossQL(), 50 metadata.getMethod().getReturnType(), 51 metadata.getMethod().getParameterTypes(), 52 metadata); 53 } 54 catch(Throwable t) 55 { 56 t.printStackTrace(); 57 throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); 58 } 59 60 sql = compiler.getSQL(); 61 62 log = Logger.getLogger(getClass().getName() + "." + entity.getEntityName() + "#" + metadata.getMethod().getName()); 63 log.debug("sql: " + sql); 64 65 setParameters(compiler.getInputParameters()); 66 setResultType(metadata.getMethod().getReturnType()); 67 68 if(!compiler.isSelectEntity()) 69 { 70 if(compiler.isSelectField()) 71 { 72 setFieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); 73 } 74 else 75 { 76 setFunctionReader(compiler.getSelectFunction()); 77 } 78 } 79 else 80 { 81 setEntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); 82 } 83 } 84 } 85 | Popular Tags |