EJB: How to retrive foreign key values from a 1-N relation?

E

Eric Ford

Need help in order to retrive the foreign key values from a 1-N relation.
I have 2 tables, User and Friend, where a User can have many Friends.
The User table has id as PK, while the Friend table has id as PK and userId
as FK.
The issiue is that I need to pick out instances of Friend that match a
certain userid, so I somehow need to reference the foreign key column.
Corresponding to the 2 tables, I have a UserBean and a FriendBean, both of
which are CMP's. I'm also using X-Doclet to generate interfaces, etc.

So far I've been able to get ahold of instances of FriendBean, but these do
not include the FK-column. I've also tried using a finder-method in the
UserBean, along these lines:

@ejb.finder
signature = "Integer findByFriendId
( java.lang.Integer userid ) "
query = "SELECT OBJECT(a) FROM User a WHERE a.Friend.id = ?1"
result-type-mapping = "Local"

This didn't work either. Can anyone help me out on this one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top