Lombock

Java Library to minimize boilerplate code.

Pitfalls with Hibernate ORM Framework

Entities classes

Avoid the @ToString Annotation on Entity classes. Careful, the @Data Annotation implicitly generates a toString() method as well.

If you set the FetchType of an association to LAZY or use the default fetching of a many-to-many association, Hibernate will try to read the association from the database. If you’re doing this within an active Hibernate Session, this will cause an additional query and slow down your application. Worse yet is if you do it without an active Hibernate Session. In that case, Hibernate throws a LazyInitializationException.

Avoid this by annotating all lazy-loaded Fields with @ToString.Exclude.

Source