-->
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: lazy="true" ignored??
PostPosted: Tue Feb 21, 2006 9:49 am 
Newbie

Joined: Tue Feb 21, 2006 9:17 am
Posts: 2
Location: london
Hi

I don't want to load up a supervisor's supervisees unless necessary - I've set the set to lazy="true" but whenever I load the supervisor I get all the supervisees.

I've tried using a non-composite id for student enrolement but it made no difference.

I'm running this in spring. The supervisor load method is:

public class StudentSupervisorManagerDaoHibernate extends HibernateDaoSupport implements StudentSupervisorManagerDao {

public StudentSupervisor load(StudentSupervisor s)
{
return getHibernateTemplate().load(s,s.getId());
}

any clues on how to proceed with this?

thanks
Ron

b]Hibernate version:[/b] 3.1.2

Mapping documents:<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- Supervisor is an abstract class -->
<class name="uk.ac.lse.spring.modulechoice.bus.Supervisor"
schema="GRAD_COURSE_CHOICE_OWNER"
table="V_GRADUATE_SUPERVISORS"
discriminator-value="X"> <!-- no instances this -->
<meta attribute="class-description">
Represent a single instance of a student supervisor in the database.
</meta>


<id name="id" column="supervisor_id">
<generator class="native" />
</id>

<discriminator column="hibernate_subclass" type="string"/>

<property name="name" type="string" not-null="true" />
<property name="email" type="string" not-null="false" />
<property name="playref" column="play_ref" type="string" not-null="false" />



<subclass name="uk.ac.lse.spring.modulechoice.bus.StudentSupervisor" discriminator-value="SS">

<set name="supervisees" schema="GRAD_COURSE_CHOICE_OWNER" inverse="true" lazy="true" table="V_GRADUATE_SUPERVISOR_STUDENTS" cascade="none" >
<key>
<column name="supervisor_id"/>
</key>
<many-to-many class="uk.ac.lse.spring.modulechoice.bus.StudentEnrolement">
<column name="setid"/>
<column name="studentid"/>
</many-to-many>
</set>

<subclass name="uk.ac.lse.spring.modulechoice.bus.ProgrammeDirector" discriminator-value="PD">
<set name="programmes" table="PROGRAMME_DIRECTOR_PROGRAMMES" where="subclass='PD'" cascade="none" lazy="true" >
<key>
<column name="supervisor_id"/>
</key>
<many-to-many class="uk.ac.lse.spring.modulechoice.bus.Course">
<column name="setid"/>
<column name="courseid"/>
</many-to-many>
</set>

<subclass name="uk.ac.lse.spring.modulechoice.bus.ProgrammeDepartmentalAdministrator" discriminator-value="DA"/>

</subclass>

</subclass>

</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="GRAD_COURSE_CHOICE_OWNER">
<class name="uk.ac.lse.spring.modulechoice.bus.StudentEnrolement"
table="V_HIB_STU_ENROLMENTS">
<meta attribute="class-description">
Represent a student enrolement on prog of study, courses etc (a 'session student').
@author ron
</meta>

<!--cache usage="read-only"/-->
<composite-id>
<key-property name="setid" column="setid"/>
<key-property name="studentid" column="studentid"/>
</composite-id>

<property name="studentid" column="studentid" insert="false" update="false"/>

<property name="courseyear" column="courseyear" insert="false" update="false"/>
<property name="deptid" column="deptid" insert="false" update="false"/>


<many-to-one name="course" class="uk.ac.lse.spring.modulechoice.bus.Course" update="false" insert="false">
<column name="setid" />
<column name="courseid" />
</many-to-one>

<set name="modules" lazy="true" table="V_STUDENT_MODULES" cascade="all" batch-size="4">
<!-- do not cache usage="read-write"/-->
<key>
<column name="setid"/>
<column name="studentid"/>
</key>
<many-to-many class="uk.ac.lse.spring.modulechoice.bus.Module" >
<column name="module_setid" />
<column name="owner"/>
<column name="moduleid"/>
</many-to-many>
</set>

<set name="supervisors"
lazy="true"
schema="GRAD_COURSE_CHOICE_OWNER"
table="V_GRADUATE_SUPERVISOR_STUDENTS"
cascade="none"
>
<key>
<column name="setid"/>
<column name="studentid"/>
</key>
<many-to-many class="uk.ac.lse.spring.modulechoice.bus.Supervisor" column="supervisor_id"/>
</set>


<many-to-one name="student"
class="uk.ac.lse.spring.modulechoice.bus.Student"
formula="studentid"
insert="false"
update="false"
outer-join="false"
not-null="true"
cascade="none"/>

<many-to-one name="studentCourseChoiceNote"
class="uk.ac.lse.spring.modulechoice.bus.StudentCourseChoiceNote"
column="student_note_id"
insert="false"
update="false"
outer-join="true"
not-null="false"
cascade="none"/>

<many-to-one name="studentSupervisorCourseChoiceNote"
class="uk.ac.lse.spring.modulechoice.bus.StudentSupervisorCourseChoiceNote"
column="supervisor_note_id"
insert="false"
update="false"
outer-join="true"
not-null="false"
cascade="none"/>

<many-to-one name="studentSupervisorCourseChoiceApproval"
class="uk.ac.lse.spring.modulechoice.bus.StudentSupervisorCourseChoiceApproval"
column="approval_id"
insert="false"
update="false"
outer-join="true"
not-null="false"
cascade="none"/>

</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

public void testGetStudentSupervisor()
{
StudentSupervisor s = new StudentSupervisor();
s.setId("133983SS");
s = pm.load(s);
assertEquals(s.getEmail(),"an.email@blah");
}

Full stack trace of any exception that occurs:

Name and version of the database you are using:

<RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
[junit] With the Partitioning, OLAP and Oracle Data Mining options

The generated SQL (show_sql=true):
[junit] Hibernate: select studentsup0_.supervisor_id as supervisor1_6_0_, studentsup0_.name as name6_0_, studentsup0_.email as email6_0_, studentsup0_.play_ref as play5_6_0_, studentsup0_.hibernate_subclass as hibernate2_6_0_ from GRAD_COURSE_CHOICE_OWNER.V_GRADUATE_SUPERVISORS studentsup0_ where studentsup0_.supervisor_id=? and studentsup0_.hibernate_subclass in ('SS', 'DA', 'PD')
[junit] Hibernate: select supervisee0_.supervisor_id as supervisor3_4_, supervisee0_.setid as setid4_, supervisee0_.studentid as studentid4_, studentenr1_.setid as setid2_0_, studentenr1_.studentid as studentid2_0_, studentenr1_.courseyear as courseyear2_0_, studentenr1_.deptid as deptid2_0_, studentenr1_.courseid as courseid2_0_, studentenr1_.student_note_id as student6_2_0_, studentenr1_.supervisor_note_id as supervisor7_2_0_, studentenr1_.approval_id as approval8_2_0_, studentenr1_.studentid as formula0_0_, studentcou2_.id as id9_1_, studentcou2_.setid as setid9_1_, studentcou2_.studentid as studentid9_1_, studentcou2_.updater_id as updater5_9_1_, studentcou2_.text as text9_1_, studentcou2_.date_updated as date7_9_1_, studentcou2_.within_regs as within8_9_1_, studentsup3_.id as id9_2_, studentsup3_.setid as setid9_2_, studentsup3_.studentid as studentid9_2_, studentsup3_.updater_id as updater5_9_2_, studentsup3_.text as text9_2_, studentsup3_.date_updated as date7_9_2_, studentsup4_.approval_id as approval1_8_3_, studentsup4_.supervisor_id as supervisor3_8_3_, studentsup4_.approved as approved8_3_, studentsup4_.date_updated as date5_8_3_, studentsup4_.setid as setid8_3_, studentsup4_.studentid as studentid8_3_ from GRAD_COURSE_CHOICE_OWNER.V_GRADUATE_SUPERVISOR_STUDENTS supervisee0_, GRAD_COURSE_CHOICE_OWNER.V_HIB_STU_ENROLMENTS studentenr1_, GRAD_COURSE_CHOICE_OWNER.COURSE_CHOICE_NOTES studentcou2_, GRAD_COURSE_CHOICE_OWNER.COURSE_CHOICE_NOTES studentsup3_, GRAD_COURSE_CHOICE_OWNER.V_APPROVALS studentsup4_ where supervisee0_.setid=studentenr1_.setid(+) and supervisee0_.studentid=studentenr1_.studentid(+) and studentenr1_.student_note_id=studentcou2_.id(+) and studentenr1_.supervisor_note_id=studentsup3_.id(+) and studentenr1_.approval_id=studentsup4_.approval_id(+) and supervisee0_.supervisor_id=?

Debug level Hibernate log excerpt:
[junit] 2006-02-21 13:36:54,094 DEBUG [org.hibernate.SQL] - <select studentsup0_.supervisor_id as supervisor1_6_0_, studentsup0_.name as name6_0_, studentsup0_.email as email6_0_, studentsup0_.play_ref as play5_6_0_, studentsup0_.hibernate_subclass as hibernate2_6_0_ from GRAD_COURSE_CHOICE_OWNER.V_GRADUATE_SUPERVISORS studentsup0_ where studentsup0_.supervisor_id=? and studentsup0_.hibernate_subclass in ('SS', 'DA', 'PD')>
[junit] 2006-02-21 13:36:54,094 DEBUG [org.hibernate.SQL] - <select studentsup0_.supervisor_id as supervisor1_6_0_, studentsup0_.name as name6_0_, studentsup0_.email as email6_0_, studentsup0_.play_ref as play5_6_0_, studentsup0_.hibernate_subclass as hibernate2_6_0_ from GRAD_COURSE_CHOICE_OWNER.V_GRADUATE_SUPERVISORS studentsup0_ where studentsup0_.supervisor_id=? and studentsup0_.hibernate_subclass in ('SS', 'DA', 'PD')>
[junit] Hibernate: select studentsup0_.supervisor_id as supervisor1_6_0_, studentsup0_.name as name6_0_, studentsup0_.email as email6_0_, studentsup0_.play_ref as play5_6_0_, studentsup0_.hibernate_subclass as hibernate2_6_0_ from GRAD_COURSE_CHOICE_OWNER.V_GRADUATE_SUPERVISORS studentsup0_ where studentsup0_.supervisor_id=? and studentsup0_.hibernate_subclass in ('SS', 'DA', 'PD')
[junit] 2006-02-21 13:36:54,094 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
[junit] 2006-02-21 13:36:54,094 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
[junit] 2006-02-21 13:36:54,207 DEBUG [org.hibernate.type.StringType] - <binding '133983SS' to parameter: 1>
[junit] 2006-02-21 13:36:54,207 DEBUG [org.hibernate.type.StringType] - <binding '133983SS' to parameter: 1>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open ResultSet (open ResultSets: 0, globally: 0)>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open ResultSet (open ResultSets: 0, globally: 0)>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.loader.Loader] - <processing result set>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.loader.Loader] - <processing result set>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.loader.Loader] - <result set row: 0>
[junit] 2006-02-21 13:36:54,811 DEBUG [org.hibernate.loader.Loader] - <result set row: 0>
[junit] 2006-02-21 13:36:54,812 DEBUG [org.hibernate.loader.Loader] - <result row: EntityKey[uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,812 DEBUG [org.hibernate.loader.Loader] - <result row: EntityKey[uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,812 DEBUG [org.hibernate.type.StringType] - <returning 'SS' as column: hibernate2_6_0_>
[junit] 2006-02-21 13:36:54,812 DEBUG [org.hibernate.type.StringType] - <returning 'SS' as column: hibernate2_6_0_>
[junit] 2006-02-21 13:36:54,813 DEBUG [org.hibernate.loader.Loader] - <Initializing object from ResultSet: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,813 DEBUG [org.hibernate.loader.Loader] - <Initializing object from ResultSet: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] - <Hydrating entity: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] - <Hydrating entity: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning 'Dr X' as column: name6_0_>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning 'Dr X' as column: name6_0_>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning 'x.blah' as column: email6_0_>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning 'x.blah' as column: email6_0_>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning '133983' as column: play5_6_0_>
[junit] 2006-02-21 13:36:54,820 DEBUG [org.hibernate.type.StringType] - <returning '133983' as column: play5_6_0_>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.loader.Loader] - <done processing result set (1 rows)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.loader.Loader] - <done processing result set (1 rows)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close ResultSet (open ResultSets: 1, globally: 1)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close ResultSet (open ResultSets: 1, globally: 1)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close PreparedStatement (open PreparedStatements: 1, globally: 1)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close PreparedStatement (open PreparedStatements: 1, globally: 1)>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <closing statement>
[junit] 2006-02-21 13:36:54,823 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <closing statement>
[junit] 2006-02-21 13:36:54,828 DEBUG [org.hibernate.loader.Loader] - <total objects hydrated: 1>
[junit] 2006-02-21 13:36:54,828 DEBUG [org.hibernate.loader.Loader] - <total objects hydrated: 1>
[junit] 2006-02-21 13:36:54,828 DEBUG [org.hibernate.engine.TwoPhaseLoad] - <resolving associations for [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,828 DEBUG [org.hibernate.engine.TwoPhaseLoad] - <resolving associations for [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor#133983SS]>
[junit] 2006-02-21 13:36:54,835 DEBUG [org.hibernate.engine.CollectionLoadContext] - <creating collection wrapper:[uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,835 DEBUG [org.hibernate.engine.CollectionLoadContext] - <creating collection wrapper:[uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <initializing collection [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <initializing collection [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <checking second-level cache>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <checking second-level cache>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <collection not cached>
[junit] 2006-02-21 13:36:54,843 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] - <collection not cached>
[junit] 2006-02-21 13:36:54,844 DEBUG [org.hibernate.loader.Loader] - <loading collection: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,844 DEBUG [org.hibernate.loader.Loader] - <loading collection: [uk.ac.lse.spring.modulechoice.bus.StudentSupervisor.supervisees#133983SS]>
[junit] 2006-02-21 13:36:54,844 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open PreparedStatement (open PreparedStatements: 0, globally: 0)>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 10:56 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The two most likely explanations are that some or all of your various data classes are final (final classes can't be extended by CGLib, so they can't be lazily loaded), or else you're not using CGLib at all. I can't remember how that's done, but check your hibernate config files to ensure that you haven't turned off cglib.


Top
 Profile  
 
 Post subject: cglib
PostPosted: Fri Feb 24, 2006 11:03 am 
Newbie

Joined: Tue Feb 21, 2006 9:17 am
Posts: 2
Location: london
thanks for responding.

You are right, the class isn't being subclassed by cglib.

cglib loads up and other classes in the same test suite are subclassed by cglib,

whilst there are some final methods in the supervisor classes the classes themselves are not final.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 26, 2006 5:23 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Try making all methods not final, see if that helps.


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.