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