[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5728) LazyInitializationException even when session is open

Pushkar Prakash (JIRA) noreply at atlassian.com
Wed Nov 10 23:08:13 EST 2010


LazyInitializationException even when session is open
-----------------------------------------------------

                 Key: HHH-5728
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5728
             Project: Hibernate Core
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.6
         Environment: Hibernate 3.2.6 GA
Database:    mysql-5.1.36
Jdbc driver:   mysql connector java 5.1.10 
OS:              Win XP Pro
            Reporter: Pushkar Prakash
         Attachments: test case.zip

The test case implements a Many-One association (Employee - Department).
After loading a department I access the employees collections.
When I call the Set.iterator() method on the employees collection implemented as Set Hibernate
throws LazyInitializationException. 
This happens whether I specify the inverse="true" on the <set> element in the mapping file or not.


Here is the complete stack trace:

Hibernate: select department0_.departmentId as departme1_1_, department0_.location as location1_ from Department department0_ where department0_.departmentId=1
Employees in department: 1
Hibernate: select employees0_.deptId as deptId1_, employees0_.emp_id as emp1_1_, employees0_.emp_id as emp1_0_0_, employees0_.fname as fname0_0_, employees0_.lname as lname0_0_, employees0_.phone as phone0_0_, employees0_.deptId as deptId0_0_ from employee employees0_ where employees0_.deptId=?
Nov 11, 2010 9:18:29 AM org.hibernate.LazyInitializationException <init>
SEVERE: 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:411)
	at Department.hashCode(Department.java:43)
	at Employee.hashCode(Employee.java:55)
	at java.util.HashMap.put(HashMap.java:418)
	at java.util.HashSet.add(HashSet.java:194)
	at java.util.AbstractCollection.addAll(AbstractCollection.java:318)
	at org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:329)
	at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:240)
	at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:222)
	at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:195)
	at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865)
	at org.hibernate.loader.Loader.doQuery(Loader.java:729)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
	at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
	at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
	at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
	at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
	at Test3.main(Test3.java:26)
ex: org.hibernate.LazyInitializationException: illegal access to loading collection


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list