An error occurred while unit testing

When testing a query An error occurred org.hibernate.LazyInitializationException: could not initialize proxy [com.xcu.domain.Customer # 1] - no Session, as shown below

 

 The reason is because of the way the use of the test unit for testing, and all operations in a transaction is not carried out to complete them.

The solution is to add annotation @Transactional @test unit tests

 

Guess you like

Origin www.cnblogs.com/lxxcn/p/11617173.html