-->
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: Fetch foreign key as a property
PostPosted: Wed Mar 12, 2008 8:22 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 4:00 am
Posts: 41
Hello everybody!

Is it possible to fetch a foreign key as a property?

it actually is if I map the foreignkeycolumn as a property. But when exporting the database schema I get a duplicate columnname exception.
I'm looking for a cleaner way to do so..

thx in advance & kind regards!


Top
 Profile  
 
 Post subject: Fetch foreign key as a property
PostPosted: Thu Mar 27, 2008 8:20 am 
Newbie

Joined: Thu Mar 27, 2008 7:57 am
Posts: 2
If you use the "Proxy fetching" strategy the calling of the getIdentifier() will not fetch the entity.

A.getB().getId() wil return the FK without a fetch.

If you want to look into the source: net.sf.hibernate.proxy.LazyInitializer
R.
Tom

_________________
GTalk: tola2000@gmail.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 5:24 am 
Beginner
Beginner

Joined: Wed Jan 16, 2008 4:00 am
Posts: 41
allright... as this issue still remains unsolved, here's how I try to get the id (remember: "NHibernate" and asp.net!)

string id = A.b.Id;

I have not implemented methods as getters and setters... just members!

However, id always ends up to be null!

What am i doing wrong? When debugging, A.b is : {CProxyTypeAndNamespaceGoesHere_NHibernate_ProxyINHibernateProxy_System_Runtime_SerializationISerializable2}, but A.b.Id = null

I know that the Id must be somehwere in the proxy object, but I can't get - even if i try to cast B - just as a test of course


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 6:32 am 
Newbie

Joined: Thu Mar 27, 2008 7:57 am
Posts: 2
LOL,
I was not aware that I ended up on a .net forum :-)

We had in Hibernate this problem:
http://forum.hibernate.org/viewtopic.ph ... hing+getid

I'm not aware if this problem also resembles in NHibernate, but it seems to be more or less the same.
Good luck,
Tom

_________________
GTalk: tola2000@gmail.com


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.