[jboss-user] [JBoss Seam] - how to configure a session bean managing entity beans with @
do-not-reply at jboss.com
Wed Jul 19 22:08:41 EDT 2006
I would like to have a web page where a user can manage "groups" that he or she belongs to. There are entity beans for users and groups, which have a @ManyToMany relationship (where I've set the user as the owning side). The MessageManagerBean class in the examples seemed very similar to what I need, so I started with that and made a "groupManager" stateful session bean; the user is injected from having logged in and the @DataModel is a list of the groups that the user belongs to. The user entity bean has a collection of groups and the group entity bean has a collection of users, with appropriate EJB3 annotations. When I try to bring up the group management page that references the group manager bean, I get:
| org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.orgmob.member.User.groups, no session or session was closed
I looked at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=85894&start=0, which seems to suggest using eager fetching for this, but since there's a many-to-many relationship, I'd have the risk of pulling the entire user and group tables into memory, wouldn't I?
What's the right approach for this? Thanks in advance and apologies if I've missed previously posted discussion or documentation or am misunderstanding eager fetching.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3959400#3959400
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3959400
More information about the jboss-user