How to avoid the LazyInitializationException

As I started to work to a small project based on Spring MVC + JPA2/Hibernate + Rest, I faced this interesting exception which is known asĀ LazyInitializationException.

Before we discuss about the exact error and the solution, let me show you what I did and I came up to face that issue.

As I said before I had a project which is using JPA2/Hibernate, so I provided some entities and daos in order to communicate and get data from my database.

For example I had the Table User(Getters/Setters are omitted):

Subscribe to RSS - hibernate