Finder methods always return the type in whose home interface they are defined, according to the spec: "The return
type of a finder method on the local home interface must be the entity bean’s local interface, or a type
representing a collection of objects that implement the entity bean’s local interface."
You need to use a select method & a getter to get a relation (or use CMR).
Dave
| Davide Pozza <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED] 06/04/2003 08:33 AM
|
To: Jboss <[EMAIL PROTECTED]> cc: Subject: [JBoss-user] EJBQL problem |
Hi,
I have a problem with an EjbQl: on my scenario, there are 2 entity
beans:
Bean1 and Bean2. There is a unidirectional relation between Bean2 and
Bean1 (M:1).
On my Bean2 I have an EjbQl (findXXX) returning a Collection, like this:
SELECT DISTINCT o.bean1 FROM bean2 AS o WHERE bean2.bean1.code=?1
When I try to cicle on the collection to retrieve every single element,
a ClassCastException is thrown:
example:
//-->BEGIN<--
// we are on a session facade........
Collection all = Bean2LocalHome.findXXX(code);
Iterator itr = all.iterator();
while (itr.hasNext()){
Bean1 bean1 = (Bean1)itr.next();//--> ClassCastException!!!!!
.....
}
//-->END<--
I don't understand: the finder is defined on Bean2 but it should return
a Bean1 collection...or not ?
Thanks
Davide
signature.asc
Description: Binary data
