-->
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: FETCHMODE issue (new to hibernate)
PostPosted: Thu Mar 15, 2012 5:44 am 
Newbie

Joined: Thu Mar 15, 2012 5:20 am
Posts: 1
Hi Friends,
I am new to Hibernate ( 2.5x) and learning it daily.
I am facing issue FETCH.LAZY

I have student-courses one-to-many mapping (collection of courses)
Below is java code :-

function () {

Criteria criteria = getSession().createCriteria(Student.class);
try {
criteria.add(Expression.eq("id", id))
.setFetchMode("courseList",FetchMode.LAZY);

Student student = (Student) criteria.uniqueResult();
return student;
}
}

student model

public class Student
{
private Long id;
private String firstName;
private String lastName;
private Integer age;
private List<Course> courseList;
......
}

<!-- List of course enrolled student mapping -->
<bag name="courseList" table="Student_Courses" lazy="true">
<key column="student_id"/>
<many-to-many column="course_id" class="springapp.domain.Course" />
</bag>

MY PROBLEM : Even I set FECTH mode lazy , I am getting CourseList initialised for that student. If I use Spring's HibernateTemplates get() then courseList collection is NOT initialised. But when I use Criteria API as above or HQL , courseList collection is initialised. I do not want this.

I seach google for half day and found that it is know issue still 3.x . Am I correct ?
Please check - https://hibernate.onjira.com/browse/HHH-3524

Any Help on this really appreciated.
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.