[jboss-user] [EJB 3.0] - Re: query.getResultList(); <= contains the same instance X t

jblackmore do-not-reply at jboss.com
Wed Nov 15 17:30:36 EST 2006


Do you have any collections on that entity? Are you using EJBQL with joins? I think I stumbled over a  related scenario, except I'm calling 'getSingleResult' and getting an exception that there are 6 or 8 or 124 elements. No code or queries or even data changed since 4.0.4 in my case, and this just started happening after moving to 4.0.5. 

I think the problem is that there may be only one instance of TABLE1 but 10 of some mapped OneToMany collection of your entity. I used a SortedSet instead of the default List (generated by Hibernate tools) to eliminate dups in 4.0.4, but that approach doesn't seem to do the trick any more. The other thing you can do is wrap the result list with a LinkedHashSet, to eliminate dups and preserve the order. It occurs to me that this is all part of the "paradigm mismatch", but I feel like I shouldn't have to do that, Hibernate should. But it works. 

Please see this post for my "fix" that got me from 4.0.2 to 4.0.4, but now I have to go back into every EJBQL query invoked throughout the system and wrap it with a LinkedHashSet. Sigh, job security. :-)  

/index.html?module=bb&op=viewtopic&t=82946&start=10

Anyone know a better solution? 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3986322#3986322

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3986322



More information about the jboss-user mailing list