Dynamic finders using ejbSelect
bsreekanth Jul 24, 2002 4:40 PMI am trying to create a dynamic finder using ejbSelect
When I try to access the methods of local object (getting it from collection returned by dynamic finder) it's throwing exception.
Dynamic finder is returning collection object. The size of collection is correct
My code is like this.
Home:
--------
public Collection findDynamicQuery() throws FinderException;
Bean:
--------
public abstract Collection ejbSelectGeneric(String jbossQl, Object[] arguments) throws FinderException;
public Collection ejbFindDynamicQuery() throws FinderException {
//construct jbossql and object array
// call ejbSelectGeneric
}
ejb-jar
--------
<query-method>
<method-name>findDynamicQuery</method-name>
<method-params/></query-method>
<ejb-ql><![CDATA[ SELECT OBJECT(alert) FROM Alert ]]>
</ejb-ql>
<query-method>
<method-name>ejbSelectGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.Object[]</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[ SELECT OBJECT(alert) FROM TdAlert ]]>
</ejb-ql>
josscmp-jdbc.xml
-----------------
<query-method><method-name>findDynamicQuery</method-name><method-params/></query-method>
<query-method>
<method-name>ejbSelectGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.Object[]</method-param>
</method-params>
</query-method>
<dynamic-ql />
client:
-------
The call to findDynamicQuery() is returning a collection of local objects.
But When I try to invoke a getMethod on the object it,s throwing following error.
java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.lang.reflect.Field.get(Native Method)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.getPrimaryKeyValue(JDBCAbstractCMPFieldBridge.java:182)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.injectPrimaryKeyIntoInstance(JDBCEntityBridge.java:587)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:70)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:62)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:572)
at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:410)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:262)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:152)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:107)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:69)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:176)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:183)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:493)
at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:296)
at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
......
.......
2002-07-24 14:12:07,551 ERROR [STDERR] java.lang.reflect.InvocationTargetException:
2002-07-24 14:12:07,551 ERROR [STDERR] javax.ejb.TransactionRolledbackLocalException: Internal error getting primary key field member idAlert; CausedByException is:
object is not an instance of declaring class; nested exception is:
javax.ejb.EJBException: Internal error getting primary key field member idAlert; CausedByException is:
object is not an instance of declaring class; CausedByException is:
Internal error getting primary key field member idAlert; CausedByException is:
object is not an instance of declaring class; nested exception is:
javax.ejb.EJBException: Internal error getting primary key field member idAlert; CausedByException is:
object is not an instance of declaring class
2002-07-24 14:12:07,551 ERROR [STDERR] at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.invoke(BaseLocalContainerInvoker.java:313)
2002-07-24 14:12:07,551 ERROR [STDERR] at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:38)
....
......
Can any body have any idea.
thanks,
sreek