-->
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... dealing only with the foreign key...
PostPosted: Mon Mar 27, 2006 3:53 am 
Newbie

Joined: Sun Feb 05, 2006 6:24 pm
Posts: 7
I have a many to one mapping and i want only to deal with the foreign key of the mapped object instead of retrieving the whole mapped object...
Long id = myobjekt.getMappedObject().getId(); will retrieve the whole (large) MappedObjekt, and get the id, but i only want to deal with the id... Is there a way to get the foreign key value direct, without retrieving the mapped object...

I read it somewhere in the doku, but could not find it again... :-(


Top
 Profile  
 
 Post subject: perhaps
PostPosted: Tue Mar 28, 2006 4:16 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Something like this:
if ( aproxy instanceof HibernateProxy ) {
LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
if ( li.isUninitialized() ) {
return false;
}
else {
entity = li.getImplementation();
}
}
id in question = li.getIdentifier();

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.