-->
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: Polymorphism and one-to-one relationships
PostPosted: Wed Apr 27, 2005 11:48 am 
Newbie

Joined: Wed Apr 27, 2005 11:19 am
Posts: 1
Hi,
I have the following problem: I have the Class1 with a set to Class2 but this class is mapped polymorphically (has two subclasses SubClass1 and SubClass2). Now, SubClass1 has a one-to-one relationship to Class3.
I am having problems retrieving Class1->Class2.
I am trying to do it with a Criteria query that looks like:
Criteria criteria = session.createCriteria(Class1);
criteria.setFetchMode("Class2", FetchMode.EAGER);
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTRY);
criteria.list();

I have a lazy="true" in the class tag in the Class3 mapping.

Hibernate then executes a query to retrieve Class1 joined with Class2 (all in one query), this is ok so far, but then Hibernate executes 1 query per each SubClass1 object to retrieve the Class3 object associated to it. And thats my problem, I don't want to load the Class3 objects (they are mapped as lazy). I am not initializing these objects, I am sure of that. I don't know if polymorphism has anything to do here.

Any idea?

Thanks.


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.