A finder method that returns multiple entity objects can only return a java.util.Collection. If you want to guarantee no duplicates are returned, you must use the DISTINCT keyword.
A select method, however, can return java.util.Collection or java.util.Set. If you specify java.util.Set then the DISTINCT is implied if it's not there (but it's probably good form to have it there!). Check the EJB 2.0 Spec sections 10.5.6.2 and 10.5.7.2. Jason -----Original Message----- From: Javier A. Soltero [mailto:[EMAIL PROTECTED]] Sent: Monday, July 15, 2002 2:54 PM To: [EMAIL PROTECTED] Subject: [JBoss-user] problems with finders returning java.util.Set Hi, [using 3.0.1 RC1] I have defined finders in my bean which return java.util.Set. When I try a unit test to verify that the finder works correctly, I get a class cast exception thrown which suggests that the return type of the finder is really an ArrayList instead of something which implements Set. Here's the finder as it is declared in ejb-jar.xml: <query> <query-method> <method-name>findAll</method-name> <method-params> </method-params> </query-method> <result-type-mapping>Local</result-type-mapping> <ejb-ql><![CDATA[SELECT OBJECT(platform) FROM Platform AS platform]]></ejb-ql> Here's the stack from the client (cactus-test) side: [junit] Testcase: test_FindAll took 0.103 sec [junit] Caused an ERROR [junit] java.util.ArrayList [junit] java.lang.ClassCastException: java.util.ArrayList [junit] at $Proxy198.findAll(Unknown Source) [junit] at net.covalent.spider.appdef.server.entity.test.PlatformEJB_test.test_FindAll( PlatformEJB_test.java:127) [junit] at org.apache.cactus.AbstractTestCase.runServerTest(AbstractTestCase.java:524) [junit] at org.apache.cactus.AbstractTestCase.runBareServerTest(AbstractTestCase.java:4 90) [junit] at org.apache.cactus.server.AbstractTestCaller.doTest(AbstractTestCaller.java:1 48) [junit] at org.apache.cactus.server.AbstractTestController.dispatch79_handleRequest(Abs tractTestController.java;org/apache/cactus/util/log/LogAspect.java(1k):123) [junit] at org.apache.cactus.server.AbstractTestController.around79_handleRequest(Abstr actTestController.java;org/apache/cactus/util/log/LogAspect.java(1k):1140) [junit] at org.apache.cactus.server.AbstractTestController.handleRequest(AbstractTestCo ntroller.java;org/apache/cactus/util/log/LogAspect.java(1k):101) [junit] at org.apache.cactus.server.ServletTestRedirector.dispatch88_doPost(ServletTest Redirector.java;org/apache/cactus/util/log/LogAspect.java(1k):132) [junit] at org.apache.cactus.server.ServletTestRedirector.around88_doPost(ServletTestRe director.java;org/apache/cactus/util/log/LogAspect.java(1k):1140) [junit] at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector. java;org/apache/cactus/util/log/LogAspect.java(1k):118) Any help greatly appreciated. I have other finders which are defined to return Sets and they all fail in a similar way, I'm about to try to redefine them to return collections, but I'd rather not. I also just noticed that I lack the "DISTINCT" ejb-ql keyword in my select, but I was under the impression that this was not required. thanks, -javier ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
