jpa - Illegal access to loading collection (hibernate.LazyInitializationException) -


i using jpa hibernate persistence provider.

i have 1 many mapping, used

@onetomany(mappedby = "msearchpreference", cascade = cascadetype.all, fetch=fetchtype.eager) 

i can see 1 many sql statements on console, eventhough getting exception

illegal access loading collection  (hibernate.lazyinitializationexception) org.hibernate.lazyinitializationexception: illegal access loading collection     @ org.hibernate.collection.abstractpersistentcollection.initialize(abstractpersistentcollection.java:341)     @ org.hibernate.collection.abstractpersistentcollection.read(abstractpersistentcollection.java:86)     @ org.hibernate.collection.abstractpersistentcollection.readelementexistence(abstractpersistentcollection.java:142)     @ org.hibernate.collection.persistentset.add(persistentset.java:187) 

can me out other arrangements need do?

this means hibernate session has been closed when trying access new entities. 2 options solve issue are:

  • review model graph , set appropiate eager fetch type when needed.
  • set extended persistent content: @persistencecontext(type = persistencecontexttype.extended)

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -