I am having an issue with the initialization of an association in an
open session.
I am receiving an org.hibernate.LazyInitializationException: illegal access to loading collection. The explanation
illegal access seems to indicate that the child collection of StudentAssign objects is not done loading when it is assigned to the parent StudentCourse.
I am using loadQuery.setFetchMode("students.assignments", FetchMode.JOIN); for the association. The exception is thrown when a hash code is computed as part of the load/initialization on the Set assignments of the object StudentCourse.
I can see in the debug log where it is loading the Set and assigning it so I am fairly sure I have it mapped correctly.
I have included all of the requested information but this is a long post because of it.
Any help would be appreciated.
Tim Vogel
Hibernate version: 3.1.3
Domain description:
Model a College course with students and assignments.
A Course can have multiple Students enrolled.
A Course can have multiple Assignments.
A Student can be assigned multiple Assignments for a given Course.
Class:
Code:
public class Course extends AbstractEntity implements ICourse, INamedEntity {
private static final long serialVersionUID = 4896237377531197735L;
private Set<CourseAssign> assignments;
private SortedSet<StudentCourse> students;
// other attributes omitted
public Set<CourseAssign> getAssignments() {
return this.assignments;
}
public void setAssignments(Set<CourseAssign> newAssignments) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "assignments", this.assignments, newAssignments);
this.assignments = newAssignments;
this.fireModelChanged(evt);
}
public SortedSet<StudentCourse> getStudents() {
return this.students;
}
public void setStudents(SortedSet<StudentCourse> newStudents) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "students", this.students, newStudents);
this.students = newStudents;
this.fireModelChanged(evt);
}
// other methods omitted
}
public class StudentCourse extends AbstractEntity implements Comparable<StudentCourse> {
private static final long serialVersionUID = 2833458515209371393L;
private IStudent student;
private ICourse course;
private Set<StudentAssign> assignments;
// other attributes omitted
public ICourse getCourse() {
return this.course;
}
public void setCourse(ICourse course) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "course", this.course, course);
this.course = course;
this.fireModelChanged(evt);
}
public IStudent getStudent() {
return this.student;
}
public void setStudent(IStudent student) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "student", this.student, student);
this.student = student;
this.fireModelChanged(evt);
}
public Set<StudentAssign> getAssignments() {
return this.assignments;
}
public void setAssignments(Set<StudentAssign> assignments) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "assignments", this.assignments, assignments);
this.assignments = assignments;
this.fireModelChanged(evt);
}
@Override public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof StudentCourse)) {
return false;
}
StudentCourse that = (StudentCourse) obj;
boolean eq = (this.assignedSeat == null ? that.assignedSeat == null : this.assignedSeat.equals(that.assignedSeat));
eq = eq && (this.assignments == null ? that.assignments == null : this.assignments.equals(that.assignments));
eq = eq
&& (this.student == null ? that.student == null : (that.student == null ? false
: (this.student.getId().equals(that.student.getId()))));
eq = eq
&& (this.course == null ? that.course == null : (that.course == null ? false
: (this.course.getId().equals(that.course.getId()))));
eq = eq && (this.end == null ? that.end == null : this.end.equals(that.end));
eq = eq && (this.start == null ? that.start == null : this.start.equals(that.start));
return eq;
}
@Override public int hashCode() {
int result = HashCodeUtil.SEED;
result = HashCodeUtil.hash(result, this.assignedSeat);
result = HashCodeUtil.hash(result, this.assignments);
result = HashCodeUtil.hash(result, this.course.getId());
result = HashCodeUtil.hash(result, this.end);
result = HashCodeUtil.hash(result, this.start);
result = HashCodeUtil.hash(result, this.student.getId());
return result;
}
// other methods omitted
}
public class StudentAssign extends AbstractEntity {
private static final long serialVersionUID = 703324023164656284L;
private StudentCourse studentCourse;
private CourseAssign courseAssign;
// other attributes omitted
private StudentAssign() {
super();
}
public CourseAssign getCourseAssign() {
return this.courseAssign;
}
public void setCourseAssign(CourseAssign courseAssign) {
ModelChangedEvent evt = new ModelChangedEvent(this, this, "courseAssign", this.courseAssign, courseAssign);
this.courseAssign = courseAssign;
this.fireModelChanged(evt);
}
@Override public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof StudentAssign)) {
return false;
}
StudentAssign that = (StudentAssign) obj;
boolean eq = (this.assigned == null ? that.assigned == null : this.assigned.equals(that.assigned));
eq = eq && (this.completed == null ? that.completed == null : this.completed.equals(that.completed));
eq = eq && (this.courseAssign == null ? that.courseAssign == null : this.courseAssign.equals(that.courseAssign));
eq = eq && (this.due == null ? that.due == null : this.due.equals(that.due));
eq = eq && (this.earnedPoints == null ? that.earnedPoints == null : this.earnedPoints.equals(that.earnedPoints));
eq = eq
&& (this.studentCourse == null ? that.studentCourse == null : (that.studentCourse == null ? false
: (this.studentCourse.getId().equals(that.studentCourse.getId()))));
return eq;
}
@Override public int hashCode() {
int result = HashCodeUtil.SEED;
result = HashCodeUtil.hash(result, this.assigned);
result = HashCodeUtil.hash(result, this.completed);
result = HashCodeUtil.hash(result, this.courseAssign);
result = HashCodeUtil.hash(result, this.due);
result = HashCodeUtil.hash(result, this.earnedPoints);
result = HashCodeUtil.hash(result, this.studentCourse.getId());
return result;
}
public StudentCourse getStudentCourse() {
return this.studentCourse;
}
public void setStudentCourse(StudentCourse studentCourse) {
this.studentCourse = studentCourse;
}
// other methods omitted
}
Mapping documents:Code:
<class name="Course" table="course">
<id name="id" column="CourseID" type="java.lang.Long">
<generator class="native"/>
</id>
<version name="version" column="Version" unsaved-value="negative"/>
<set name="assignments" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="CourseID"/>
<one-to-many class="CourseAssign"/>
</set>
<set name="students" inverse="true" cascade="all-delete-orphan" lazy="true" sort="natural">
<key column="CourseID"/>
<one-to-many class="StudentCourse"/>
</set>
other properties here
</class>
<class name="StudentCourse" table="studentcourse">
<id name="id" column="StudentCourseID" type="java.lang.Long">
<generator class="native"/>
</id>
<version name="version" column="Version" unsaved-value="negative"/>
<many-to-one name="course" column="CourseID" class="Course" not-null="true"/>
<many-to-one name="student" column="PersonID" class="Student" not-null="true"/>
<set name="assignments" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="StudentCourseID"/>
<one-to-many class="StudentAssign"/>
</set>
other properties here
</class>
<class name="StudentAssign" table="studentassign">
<id name="id" column="StudentAssignID" type="java.lang.Long">
<generator class="native"/>
</id>
<version name="version" column="Version" unsaved-value="negative"/>
<many-to-one name="courseAssign" column="CourseAssignID" class="CourseAssign" not-null="true"/>
<many-to-one name="studentCourse" column="StudentCourseID" class="StudentCourse" not-null="true"/>
other properties here
</class>
Code between sessionFactory.openSession() and session.close():Code:
public ICourse loadCourse(Long id) {
Session session = openSession();
Criteria loadQuery = session.createCriteria(ICourse.class);
loadQuery.add(Restrictions.idEq(id));
loadQuery.setFetchMode("students", FetchMode.JOIN);
loadQuery.setFetchMode("students.assignments", FetchMode.JOIN);
loadQuery.setFetchMode("students.student", FetchMode.JOIN);
loadQuery.setFetchMode("assignments", FetchMode.JOIN);
loadQuery.setFetchMode("assignments.template", FetchMode.JOIN);
loadQuery.setFetchMode("instructor", FetchMode.JOIN);
ICourse course = (ICourse) loadQuery.uniqueResult();
session.close();
return course;
}
Full stack trace of any exception that occurs:Code:
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.equals(PersistentSet.java:350)
at rcpsample.teachersaid.domain.StudentCourse.equals(StudentCourse.java:208)
at rcpsample.teachersaid.domain.StudentCourse.compareTo(StudentCourse.java:246)
at rcpsample.teachersaid.domain.StudentCourse.compareTo(StudentCourse.java:1)
at java.util.TreeMap.compare(TreeMap.java:1093)
at java.util.TreeMap.put(TreeMap.java:465)
at java.util.TreeSet.add(TreeSet.java:210)
at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
at java.util.TreeSet.addAll(TreeSet.java:258)
at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:273)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:183)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
at rcpsample.teachersaid.db.hibernate.SessionDAOJDBC.loadCourse(SessionDAOJDBC.java:144)
at rcpsample.teachersaid.db.hibernate.SessionDAOJDBCTest.loadCourse(SessionDAOJDBCTest.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Name and version of the database you are using: MySQL, version: 4.1.9-nt-logThe generated SQL (show_sql=true):Code:
Hibernate:
select
this_.CourseID as CourseID3_5_,
this_.Version as Version3_5_,
this_.Name as Name3_5_,
assignment2_.CourseID as CourseID7_,
assignment2_.CourseAssignID as CourseAs1_7_,
assignment2_.CourseAssignID as CourseAs1_4_0_,
assignment2_.Version as Version4_0_,
assignment2_.CourseID as CourseID4_0_,
assignment2_.AssignmentID as Assignme4_4_0_,
assignment2_.PossiblePoints as Possible5_4_0_,
assignment2_.Weight as Weight4_0_,
assignment2_.GroupAssign as GroupAss7_4_0_,
assignment2_.ShortDescr as ShortDescr4_0_,
assignment2_.LongDescr as LongDescr4_0_,
assignment2_.Comment as Comment4_0_,
assignment2_.AssignedDate as Assigne11_4_0_,
assignment2_.DueDate as DueDate4_0_,
assignment3_.AssignmentID as Assignme1_1_1_,
assignment3_.Version as Version1_1_,
assignment3_.ShortDescr as ShortDescr1_1_,
assignment3_.LongDescr as LongDescr1_1_,
assignment3_.Comment as Comment1_1_,
students4_.CourseID as CourseID8_,
students4_.StudentCourseID as StudentC1_8_,
students4_.StudentCourseID as StudentC1_10_2_,
students4_.Version as Version10_2_,
students4_.CourseID as CourseID10_2_,
students4_.PersonID as PersonID10_2_,
students4_.StartDate as StartDate10_2_,
students4_.EndDate as EndDate10_2_,
students4_.AssignedSeat as Assigned7_10_2_,
student5_.PersonID as PersonID5_3_,
student5_.Version as Version5_3_,
student5_.PreferedName as Prefered4_5_3_,
student5_.FirstName as FirstName5_3_,
student5_.MiddleName as MiddleName5_3_,
student5_.LastName as LastName5_3_,
student5_.SuffixName as SuffixName5_3_,
student5_.LogonName as LogonName5_3_,
student5_.Comment as Comment5_3_,
student5_.Gender as Gender5_3_,
student5_.Role as Role5_3_,
assignment6_.StudentCourseID as StudentC4_9_,
assignment6_.StudentAssignID as StudentA1_9_,
assignment6_.StudentAssignID as StudentA1_9_4_,
assignment6_.Version as Version9_4_,
assignment6_.CourseAssignID as CourseAs3_9_4_,
assignment6_.StudentCourseID as StudentC4_9_4_,
assignment6_.AssignedDate as Assigned5_9_4_,
assignment6_.DueDate as DueDate9_4_,
assignment6_.CompletedDate as Complete7_9_4_,
assignment6_.EarnedPoints as EarnedPo8_9_4_
from
course this_
left outer join courseassign assignment2_ on this_.CourseID=assignment2_.CourseID
left outer join assignment assignment3_ on assignment2_.AssignmentID=assignment3_.AssignmentID
left outer join studentcourse students4_ on this_.CourseID=students4_.CourseID
left outer join person student5_ on students4_.PersonID=student5_.PersonID
left outer join studentassign assignment6_ on students4_.StudentCourseID=assignment6_.StudentCourseID
where
this_.CourseID = ?
Debug level Hibernate log excerpt:Code:
DEBUG [org.hibernate.impl.SessionImpl:219] - <opened session at timestamp: 4697971644125184>
DEBUG [org.hibernate.jdbc.AbstractBatcher:311] - <about to open PreparedStatement (open PreparedStatements: 0, globally: 0)>
DEBUG [org.hibernate.jdbc.ConnectionManager:415] - <opening JDBC connection>
DEBUG [org.hibernate.SQL:346] - <select this_.CourseID as CourseID3_5_, this_.Version as Version3_5_, this_.Name as Name3_5_, assignment2_.CourseID as CourseID7_, assignment2_.CourseAssignID as CourseAs1_7_, assignment2_.CourseAssignID as CourseAs1_4_0_, assignment2_.Version as Version4_0_, assignment2_.CourseID as CourseID4_0_, assignment2_.AssignmentID as Assignme4_4_0_, assignment2_.PossiblePoints as Possible5_4_0_, assignment2_.Weight as Weight4_0_, assignment2_.GroupAssign as GroupAss7_4_0_, assignment2_.ShortDescr as ShortDescr4_0_, assignment2_.LongDescr as LongDescr4_0_, assignment2_.Comment as Comment4_0_, assignment2_.AssignedDate as Assigne11_4_0_, assignment2_.DueDate as DueDate4_0_, assignment3_.AssignmentID as Assignme1_1_1_, assignment3_.Version as Version1_1_, assignment3_.ShortDescr as ShortDescr1_1_, assignment3_.LongDescr as LongDescr1_1_, assignment3_.Comment as Comment1_1_, students4_.CourseID as CourseID8_, students4_.StudentCourseID as StudentC1_8_, students4_.StudentCourseID as StudentC1_10_2_, students4_.Version as Version10_2_, students4_.CourseID as CourseID10_2_, students4_.PersonID as PersonID10_2_, students4_.StartDate as StartDate10_2_, students4_.EndDate as EndDate10_2_, students4_.AssignedSeat as Assigned7_10_2_, student5_.PersonID as PersonID5_3_, student5_.Version as Version5_3_, student5_.PreferedName as Prefered4_5_3_, student5_.FirstName as FirstName5_3_, student5_.MiddleName as MiddleName5_3_, student5_.LastName as LastName5_3_, student5_.SuffixName as SuffixName5_3_, student5_.LogonName as LogonName5_3_, student5_.Comment as Comment5_3_, student5_.Gender as Gender5_3_, student5_.Role as Role5_3_, assignment6_.StudentCourseID as StudentC4_9_, assignment6_.StudentAssignID as StudentA1_9_, assignment6_.StudentAssignID as StudentA1_9_4_, assignment6_.Version as Version9_4_, assignment6_.CourseAssignID as CourseAs3_9_4_, assignment6_.StudentCourseID as StudentC4_9_4_, assignment6_.AssignedDate as Assigned5_9_4_, assignment6_.DueDate as DueDate9_4_, assignment6_.CompletedDate as Complete7_9_4_, assignment6_.EarnedPoints as EarnedPo8_9_4_ from course this_ left outer join courseassign assignment2_ on this_.CourseID=assignment2_.CourseID left outer join assignment assignment3_ on assignment2_.AssignmentID=assignment3_.AssignmentID left outer join studentcourse students4_ on this_.CourseID=students4_.CourseID left outer join person student5_ on students4_.PersonID=student5_.PersonID left outer join studentassign assignment6_ on students4_.StudentCourseID=assignment6_.StudentCourseID where this_.CourseID = ?>
DEBUG [org.hibernate.jdbc.AbstractBatcher:424] - <preparing statement>
DEBUG [org.hibernate.type.LongType:80] - <binding '2' to parameter: 1>
DEBUG [org.hibernate.jdbc.AbstractBatcher:327] - <about to open ResultSet (open ResultSets: 0, globally: 0)>
DEBUG [org.hibernate.loader.Loader:682] - <processing result set>
DEBUG [org.hibernate.loader.Loader:687] - <result set row: 0>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: CourseAs1_4_0_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: Assignme1_1_1_>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentC1_10_2_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: PersonID5_3_>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentA1_9_4_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: CourseID3_5_>
DEBUG [org.hibernate.loader.Loader:1164] - <result row: EntityKey[rcpsample.teachersaid.domain.CourseAssign#1], EntityKey[rcpsample.teachersaid.domain.Assignment#2], EntityKey[rcpsample.teachersaid.domain.StudentCourse#1], EntityKey[rcpsample.teachersaid.domain.Student#2], EntityKey[rcpsample.teachersaid.domain.StudentAssign#1], EntityKey[rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '0' as column: Version4_0_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: CourseID4_0_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: Assignme4_4_0_>
DEBUG [org.hibernate.type.IntegerType:116] - <returning null as column: Possible5_4_0_>
DEBUG [org.hibernate.type.DoubleType:116] - <returning null as column: Weight4_0_>
DEBUG [org.hibernate.type.BooleanType:116] - <returning null as column: GroupAss7_4_0_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: ShortDescr4_0_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: LongDescr4_0_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: Comment4_0_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 0>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.Assignment#2]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.Assignment#2]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '0' as column: Version1_1_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'ratios db' as column: ShortDescr1_1_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'How to do ratios db' as column: LongDescr1_1_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'manually entered' as column: Comment1_1_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 0>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '0' as column: Version10_2_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: CourseID10_2_>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: PersonID10_2_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: Assigned7_10_2_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 0>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.Student#2]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.Student#2]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '0' as column: Version5_3_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: Prefered4_5_3_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'Sally' as column: FirstName5_3_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: MiddleName5_3_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'Adams' as column: LastName5_3_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: SuffixName5_3_>
DEBUG [org.hibernate.type.StringType:116] - <returning null as column: LogonName5_3_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'manually entered' as column: Comment5_3_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 0>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '999' as column: Version9_4_>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: CourseAs3_9_4_>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentC4_9_4_>
DEBUG [org.hibernate.type.IntegerType:116] - <returning null as column: EarnedPo8_9_4_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 999>
DEBUG [org.hibernate.loader.Loader:1347] - <Initializing object from ResultSet: [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.persister.entity.AbstractEntityPersister:1860] - <Hydrating entity: [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.type.IntegerType:122] - <returning '0' as column: Version3_5_>
DEBUG [org.hibernate.type.StringType:122] - <returning 'algebra I' as column: Name3_5_>
DEBUG [org.hibernate.engine.TwoPhaseLoad:75] - <Version: 0>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: CourseID7_>
DEBUG [org.hibernate.loader.Loader:972] - <found row of collection: [rcpsample.teachersaid.domain.Course.assignments#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:100] - <new collection: instantiating>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: CourseAs1_7_>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:304] - <attempting to resolve: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:313] - <resolved object in session cache: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.type.LongType:122] - <returning '2' as column: CourseID8_>
DEBUG [org.hibernate.loader.Loader:972] - <found row of collection: [rcpsample.teachersaid.domain.Course.students#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:100] - <new collection: instantiating>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentC1_8_>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:304] - <attempting to resolve: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:313] - <resolved object in session cache: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentC4_9_>
DEBUG [org.hibernate.loader.Loader:972] - <found row of collection: [rcpsample.teachersaid.domain.StudentCourse.assignments#1]>
DEBUG [org.hibernate.engine.CollectionLoadContext:100] - <new collection: instantiating>
DEBUG [org.hibernate.type.LongType:122] - <returning '1' as column: StudentA1_9_>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:304] - <attempting to resolve: [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:313] - <resolved object in session cache: [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.loader.Loader:709] - <done processing result set (1 rows)>
DEBUG [org.hibernate.jdbc.AbstractBatcher:334] - <about to close ResultSet (open ResultSets: 1, globally: 1)>
DEBUG [org.hibernate.jdbc.AbstractBatcher:319] - <about to close PreparedStatement (open PreparedStatements: 1, globally: 1)>
DEBUG [org.hibernate.jdbc.AbstractBatcher:470] - <closing statement>
DEBUG [org.hibernate.loader.Loader:839] - <total objects hydrated: 6>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.Assignment#2]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.Assignment#2]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.Assignment#2]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.Student#2]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.engine.CollectionLoadContext:132] - <returning loading collection:[rcpsample.teachersaid.domain.StudentCourse.assignments#1]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.Student#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:141] - <creating collection wrapper:[rcpsample.teachersaid.domain.Person.addresses#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:141] - <creating collection wrapper:[rcpsample.teachersaid.domain.Person.phones#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:141] - <creating collection wrapper:[rcpsample.teachersaid.domain.Student.courses#2]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.Student#2]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.CourseAssign#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:153] - <loading entity: [rcpsample.teachersaid.domain.StudentCourse#1]>
DEBUG [org.hibernate.event.def.DefaultLoadEventListener:222] - <entity found in session cache>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.StudentAssign#1]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:107] - <resolving associations for [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:132] - <returning loading collection:[rcpsample.teachersaid.domain.Course.assignments#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:132] - <returning loading collection:[rcpsample.teachersaid.domain.Course.students#2]>
DEBUG [org.hibernate.engine.TwoPhaseLoad:206] - <done materializing entity [rcpsample.teachersaid.domain.Course#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:262] - <1 collections were found in result set for role: rcpsample.teachersaid.domain.Course.assignments>
DEBUG [org.hibernate.engine.CollectionLoadContext:206] - <collection fully initialized: [rcpsample.teachersaid.domain.Course.assignments#2]>
DEBUG [org.hibernate.engine.CollectionLoadContext:272] - <1 collections initialized for role: rcpsample.teachersaid.domain.Course.assignments>
DEBUG [org.hibernate.engine.CollectionLoadContext:262] - <1 collections were found in result set for role: rcpsample.teachersaid.domain.Course.students>
ERROR [org.hibernate.LazyInitializationException:19] - <illegal access to loading collection>
org.hibernate.LazyInitializationException: illegal access to loading collection
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.PersistentSet.hashCode(PersistentSet.java:355)
at rcpsample.utils.HashCodeUtil.hash(HashCodeUtil.java:89)
at rcpsample.teachersaid.domain.StudentCourse.hashCode(StudentCourse.java:228)
at java.util.HashMap.hash(HashMap.java:264)
at java.util.HashMap.put(HashMap.java:382)
at org.hibernate.collection.PersistentSet.getSnapshot(PersistentSet.java:44)
at org.hibernate.engine.CollectionEntry.postInitialize(CollectionEntry.java:191)
at org.hibernate.engine.StatefulPersistenceContext.addInitializedCollection(StatefulPersistenceContext.java:721)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:191)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:268)
at org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:249)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:866)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:853)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305)
at rcpsample.teachersaid.db.hibernate.SessionDAOJDBC.loadCourse(SessionDAOJDBC.java:146)
at rcpsample.teachersaid.db.hibernate.SessionDAOJDBCTest.loadCourse(SessionDAOJDBCTest.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:32)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
DEBUG [org.hibernate.jdbc.JDBCContext:217] - <after autocommit>
DEBUG [org.hibernate.jdbc.ConnectionManager:296] - <transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!>
DEBUG [org.hibernate.impl.SessionImpl:417] - <after transaction completion>