Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > EJB: How to retrive foreign key values from a 1-N relation?

Reply
Thread Tools

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

 
 
Eric Ford
Guest
Posts: n/a
 
      01-14-2004
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?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate foreign key as primary key Lionel Java 9 08-10-2011 04:58 PM
Gridview error: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. Bobby Edward ASP .Net 1 10-14-2008 04:09 AM
Survey - implementing CRUD with "foreign name" instead of foreign key. H5N1 ASP .Net 0 05-03-2006 11:36 PM
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. bazzer ASP .Net 1 04-06-2006 01:31 PM
Setting foreign key values to null using property set that is a long Ratman ASP .Net 0 06-23-2004 03:44 PM



Advertisments