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.  [ 1 post ] 
Author Message
 Post subject: [NHibernate 1.1] Associations/Proxy/Fetch
PostPosted: Fri Aug 24, 2007 1:03 pm 
Newbie

Joined: Sat Jan 21, 2006 8:30 pm
Posts: 6
Hi,

I'm using NHibernate 1.1 right now and I'm having a problem when fetching something I didn't fetch in the first place (using ICriteria) on the same entity with the same session.

Example:
Person can have 1 Address and 1 Car.
The Car can be Sport or Economy (sub-classes) and "lazy" is set to true (for Car class and its subclasses)

First lookup query, I fetch Address only. Works great.
Second query (same session) I lookup the same Person and try to fetch its Car, which happens to be a Sport Car.
Then I try to cast Person.Car as a SportCar but I get a ClassCastException.
Printing the type of Person.Car, I realize it's the INHibernateProxy there.

In the logs I see the Car being "hydrated". So I know it's there somewhere in memory.
I checked the LoadedState of the Person EntityEntry and I realized its associations are not being set since its first load (it has been already loaded indeed, since I made a query for it right before this one).
So what I get is pretty much like the previous result (it's like I get the previous load state).

Loader.GetRow() checks if the entity has already been loaded.
Impl.SessionImpl.InitializeEntity() "resolve" all the associations to the entity and gets called only when the entity is not yet been loaded.

I tried to force the "re-hydration" of the entity but (of course) it doesn't work.

Any ideas?


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

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.