-->
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.  [ 4 posts ] 
Author Message
 Post subject: will this create a havoc
PostPosted: Mon Jan 17, 2005 5:52 pm 
Newbie

Joined: Thu Dec 16, 2004 2:19 pm
Posts: 12
Hi,

I am trying to keep track of entity creator, in this case an User entity.
If an user self-register, the creator would be him(her)self.

Code:
class User {
    Long id;
    String name;
    User creator;
}


User u = new User();
u.setName("foo");
u.setCreator(u);

session.saveOrUpdate(u);


I assume hibernate is clever enough to handle self-referencing entities.

-cs


Top
 Profile  
 
 Post subject: Re: will this create a havoc
PostPosted: Tue Jan 18, 2005 6:56 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
chacs wrote:
I assume hibernate is clever enough to handle self-referencing entities.

How about give it a try :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: will this create a havoc
PostPosted: Tue Jan 18, 2005 3:37 pm 
Newbie

Joined: Thu Dec 16, 2004 2:19 pm
Posts: 12
emmanuel wrote:
chacs wrote:
I assume hibernate is clever enough to handle self-referencing entities.

How about give it a try :-)


works as advertised :-)

Using the same example, does the "creator" gets loaded at the same time the "entity" got loaded ?

It seems to be doing so when I looked at the generated SQL in the log file.

How do I make the loading of the "creator" lazy ? I don't see any "lazy" attribute in the "many-to-one" element in the dtd.

-cs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
lazy="true" attribute on the class element


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.