[hibernate-dev] best approach to manage this many to many relationship

Lakers javaworld at gmail.com
Mon May 14 23:23:32 EDT 2007


Hi,

Want to implement a feature to allow a user to block a list of other users.
The use case is for any given user id, find the list of users he blocks.

I use a many-to-many relationship table to map the relationship:
user1_id, user2_id

Since there might be a huge long list of users a user want to block, I don't
want to keep a list of blockedUsers inside my user data object. May even
need to implement pagination to show the list of blocked users.

What's the best way I can use Hibernate to maintain the relationship and
answer query like: findBlockedUserListByUserId(userId).

Should I use native SQL with addEntity? Is there a better way? If the same
question has been asked,  a pointer of that thread would help.

thanks!
Derek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20070515/f42c168f/attachment.html 


More information about the hibernate-dev mailing list