-->
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: Many-to-one issue
PostPosted: Tue May 20, 2008 4:22 am 
Newbie

Joined: Sat Sep 22, 2007 2:26 am
Posts: 4
I am a newbie at NHibernate. I have a problem with "many-to-one" relations.
I have a class Node:
Code:
public class Node
{
  public int Id;
  public string Name;
  public Node Parent;
}

When I get a "Node", Parent field isn't fetched(Parent is null). In real, I don't need all Parent properties, only the "Id", and I don't want to access the table again.
So is it possible to get only the foriegn column without accessing the whole class?
Thanks for your help.

_________________
www.lotusmedya.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 20, 2008 4:38 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You have two possibilities:

1) Just map the id instead of the object
2) Use lazy loading. Hibernate will create an proxy object and handle lazy loading of the object for you. And you can access the Id getter of the object without hibernate initializing the full object (meaning no call to the db). Check the documentation for more information

_________________
--Wolfgang


Top
 Profile  
 
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.