These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Initializing a List with the correct entities.
PostPosted: Wed Jun 22, 2005 12:31 pm 
I have a User class and a Group class. Each one has a many to many association to the other through the following Sets:

public class User{

@ManyToMany
private Set<Group> groups;

and

public class Group{

@ManyToMany(mappedBy="groups")
private Set<User> users;

I've also created a subclass of User called NamedUser that adds fields for firstName and lastName. Now, I've found that if I add some NamedUser objects to a Group and issue the query "SELECT u FROM User u, INNER JOIN groups g WHERE g.name = ?" what gets returned is a list of NamedUser objects, but if I access the Users assigned to a Group via the lazy initialized collection Group.getUsers(), it contains entities of the superclass User. Is there any way that I can have the collection objects be initialized to the type of the correct subclass (i.e. NamedUser instead of User)?

Thanks in advance for your help.


Top
  
 
 Post subject: Upon further examination....
PostPosted: Wed Jun 22, 2005 4:03 pm 
I found this http://www.hibernate.org/280.html. I am trying to access the methods through reflection in a JSP page, and it seems like proxies are my problem. Does anyone know how to leave lazy fetching enabled but disable proxies? Particulary with annotations?


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.