Bugs item #951472, was opened at 2004-05-10 16:42 Message generated for change (Comment added) made by ruoso You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=951472&group_id=22866
Category: JBossCMP Group: v3.2 Status: Closed Resolution: Rejected Priority: 5 Submitted By: Daniel Ruoso (ruoso) Assigned to: Alexey Loubyansky (loubyansky) Summary: More than one entity found exception raised with subclasses Initial Comment: Hi, I have one CMP EJB called Account, and I have descendant EJBs called AccountMoney, AccountPayCheck, AccountCreditCard. These EJBs are java subclasses from the AccountBean class, and the tables inherits the Account table. Here's the problem. I have two session beans, one named CtrlPayCheck and other name CtrlAccounts. The CtrlPayCheck needs to findByPrimaryKey on an AccountPayCheck EJB, and invoke a method in CtrlAccounts to operate on the "generic" Account. When the second session bean (CtrlAccounts) tries to findByPrimaryKey the same account (as AccountLocal) that the first session bean (CtrlPayCheck) accessed (as AccountPayCheckLocal), a "More than one entity matches the find criteria" exception. In fact, the field used in the finder *is* the primary key of the account table. And there is *only one* entity that matches the find criteria... Possible cause: I think when the CMP container instantiates the AccountPayCheck EJB it sees that it must check the idAccount field into Account table, but store that information as an AccountPayCheck. which in fact *is* an Account. Then, when the container goes to instantiate the Account EJB, it gets from the database (as he never retrtieved an Account Bean) and sees that the AccountnPayCheck is a Account too, so it finds two entities, and not just one. Even they being the same entity. I've never looked at Jboss's source code, and I actually don't have a clue of where to look at. This problem is really urgent to me, as it's stopping an online situation... Hope there is a workaround before the fix is released. ---------------------------------------------------------------------- >Comment By: Daniel Ruoso (ruoso) Date: 2004-05-11 19:51 Message: Logged In: YES user_id=288034 Ok... I revised my investigation and In fact, the rs contains 2 rows... then I found that the problem is really with postgresql "inherits" implementation. The problem is: when I have the table Account have the primary key idAccount postgresql does not assure that the inherited table doesn't have the same id. It's not a JBOSS bug after all... ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-11 18:05 Message: Logged In: YES user_id=288034 Ok... I'll investigate a little more... ---------------------------------------------------------------------- Comment By: Alexey Loubyansky (loubyansky) Date: 2004-05-11 17:48 Message: Logged In: YES user_id=543482 Didn't you write that SQL query was correct and ResultSet returned wrong data? There is no query cache. We return what is in the ResultSet. ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-11 17:30 Message: Logged In: YES user_id=288034 Ok... just to make clear, JDBCAbstractQueryCommand is the last step before talking to database? I mean, there is no cache control or transaction control inside jboss after that? And... there is still the chance I misunderstood what was going on in jboss... after all, this was my first incursion in jboss source... :) ---------------------------------------------------------------------- Comment By: Alexey Loubyansky (loubyansky) Date: 2004-05-11 16:44 Message: Logged In: YES user_id=543482 Or the driver if the database really contains only one row matching the query. I mean if the SQL query is correct and ResultSet contains wrong result this is not a bug in JBoss. ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-11 13:30 Message: Logged In: YES user_id=288034 Do you mean this can be a bug in postgresql? ---------------------------------------------------------------------- Comment By: Alexey Loubyansky (loubyansky) Date: 2004-05-11 03:18 Message: Logged In: YES user_id=543482 If ResultSet contains wrong results we can't fix it. ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-10 19:07 Message: Logged In: YES user_id=288034 I made a workaround to this bug that gives more information about where exactly is the bug. I've changed the code that retrieves the Account EJB to retrieve the AccountPayCheck EJB and then the exception stopped. ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-10 18:11 Message: Logged In: YES user_id=288034 Just to make clear... I've looked at JDBCAbstractQueryCommand method execute. and definetively the ResultSet *IS* returning 2 rows, and not 1 as there is in the database... ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-10 18:05 Message: Logged In: YES user_id=288034 Ok, I've done some tests... and as far as I could go, the sql was correctly arranged. like SELECT * FROM Account WHERE idaccount=?. And, this part I really didn't understand, the result set had 2 rows. even the database having just 1. Maybe it's the transaction manager, that incercepts the execution and makes some mess... but I don't know where to look up. ---------------------------------------------------------------------- Comment By: Daniel Ruoso (ruoso) Date: 2004-05-10 17:12 Message: Logged In: YES user_id=288034 Well, I finally got the stacktrace for the error. 17:08:57,769 ERROR [STDERR] Caused by: javax.ejb.FinderException: More than one entity matches the finder criteria. 17:08:57,772 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:60) 17:08:57,775 ERROR [STDERR] at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:571) 17:08:57,778 ERROR [STDERR] at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:299) 17:08:57,781 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.findEntity(CachedConnectionInterceptor.java:300) 17:08:57,784 ERROR [STDERR] at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:637) 17:08:57,787 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) 17:08:57,790 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 17:08:57,793 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324) 17:08:57,796 ERROR [STDERR] at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1043) 17:08:57,799 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88) 17:08:57,802 ERROR [STDERR] at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:197) 17:08:57,805 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:214) 17:08:57,808 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88) 17:08:57,811 ERROR [STDERR] at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:89) 17:08:57,814 ERROR [STDERR] at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61) 17:08:57,817 ERROR [STDERR] at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28) 17:08:57,821 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88) 17:08:57,824 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267) 17:08:57,827 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:98) 17:08:57,830 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92) 17:08:57,833 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120) 17:08:57,836 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93) 17:08:57,839 ERROR [STDERR] at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:483) 17:08:57,842 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:720) 17:08:57,845 ERROR [STDERR] at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:293) 17:08:57,848 ERROR [STDERR] at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110) 17:08:57,851 ERROR [STDERR] at $Proxy316.findByPrimaryKey(Unknown Source) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=376685&aid=951472&group_id=22866 ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ JBoss-Development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development