Compund primary Key Sql generation error.
guix Apr 27, 2004 5:26 AMHi:
I have a Bean with a compound primary key. When I do a findByPrimaryKey the Sql generated is wrong.
Running on Jboss 3.2.3 with Oracle9i
Jboss generates this sql where the fields asre missing:
2004-04-27 11:49:31,195 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.StructureTradeEJB#findByPrimaryKey] Executing SQL: SELECT FROM STRUCTURETRADES WHERE
and the stack trace:
javax.ejb.FinderException: Find failed: java.sql.SQLException: ORA-00936: missing expression at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:238) at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:111) at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.execute(JDBCFindByPrimaryKeyQuery.java:108) at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:49) at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:571) at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:299) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntity(CachedConnectionInterceptor.java:300) at org.jboss.ejb.EntityContainer.find(EntityContainer.java:697) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1043) at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88) at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214) at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88) at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89) at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61) at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267) at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98) at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92) at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93) at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:483) at org.jboss.ejb.Container.invoke(Container.java:720) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546) at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367) at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) at java.lang.Thread.run(Thread.java:534) at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133) at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source) at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135) at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:96) at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46) at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45) at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:173) at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85) at $Proxy4.findByPrimaryKey(Unknown Source) at com.db.gto.cio.gm.it.madrid.rms.ejbs.StructureTradeFactory.existsStructureTrade(StructureTradeFactory.java:34)
PK class
package com.db.gto.cio.gm.it.madrid.rms.ejbs; public class StructureTradePK implements java.io.Serializable { public String structureId; public String tradeId; public StructureTradePK(){ } public StructureTradePK(String structureId ,String tradeId){ this.structureId = structureId; this.tradeId = tradeId; } public boolean equals(Object structureTradePKObject){ if (structureTradePKObject instanceof StructureTradePK) { StructureTradePK structureTradePK = (StructureTradePK)structureTradePKObject; return(structureTradePK.structureId.equals(structureId) && structureTradePK.tradeId.equals(tradeId)); } else{ return(false); } } public int hashCode(){ StringBuffer buff = new StringBuffer (); buff.append(structureId); buff.append(tradeId); int hashCode =buff.toString().hashCode(); return hashCode; } }
bean class
package com.db.gto.cio.gm.it.madrid.rms.ejbs; import javax.ejb.CreateException; import javax.ejb.EntityContext; public abstract class StructureTradeBean implements javax.ejb.EntityBean{ public StructureTradePK ejbCreate(String structureId, String tradeId) throws CreateException{ this.setStructureId(structureId); this.setTradeId(tradeId); return null; } public void ejbPostCreate(String structureId, String tradeId){} /** * Propiedades del Objeto */ public abstract String getStructureId(); public abstract String getTradeId(); public abstract void setStructureId(String structureId); public abstract void setTradeId(String tradeId); public void setEntityContext(EntityContext ctx){ // Not implemented. } public void unsetEntityContext(){ // Not implemented. } public void ejbActivate() { // Not implemented. } public void ejbPassivate() { // Not implemented. } public void ejbLoad(){ // Not implemented. } public void ejbStore() { // Not implemented. } public void ejbRemove() { // Not implemented. } }
ejb-jar
<entity> <ejb-name>StructureTradeEJB</ejb-name> <abstract-schema-name>StructureTrade</abstract-schema-name> <home>com.db.gto.cio.gm.it.madrid.rms.ejbs.StructureTradeHomeRemote</home> <remote>com.db.gto.cio.gm.it.madrid.rms.ejbs.StructureTradeRemote</remote> <ejb-class>com.db.gto.cio.gm.it.madrid.rms.ejbs.StructureTradeBean</ejb-class> <persistence-type>Container</persistence-type> <prim-key-class>com.db.gto.cio.gm.it.madrid.rms.ejbs.StructureTradePK</prim-key-class> <reentrant>False</reentrant> <cmp-version>2.x</cmp-version> <cmp-field><field-name>structureId</field-name></cmp-field> <cmp-field><field-name>tradeId</field-name></cmp-field> <security-identity><use-caller-identity/></security-identity> </entity>
jbosscmp
<entity> <ejb-name>StructureTradeEJB</ejb-name> <table-name>structuretrades</table-name> </entity>