How to solve lazy initialization exception using JPA and Hibernate as provider
Posted
by rupertin
on Stack Overflow
See other posts from Stack Overflow
or by rupertin
Published on 2009-02-23T17:04:56Z
Indexed on
2010/03/22
16:41 UTC
Read the original article
Hit count: 604
I am working on a project for a customer who wants to use lazy initialization. They always get "lazy initialization exception" when mapping classes with the default lazy loading mode.
@JoinTable(name = "join_profilo_funzionalita", joinColumns = {@JoinColumn(name = "profilo_id", referencedColumnName = "profilo_id")}, inverseJoinColumns = {@JoinColumn(name = "funzionalita_id", referencedColumnName = "funzionalita_id")})
//@ManyToMany(fetch=FetchType.EAGER) - no exceptions if uncommented
@ManyToMany
private Collection<Funzionalita> funzionalitaIdCollection;
Is there a standard pattern using JPA classes to avoid this error?
Snippets are welcome, thanks a lot for your time.
© Stack Overflow or respective owner