Skip to content

EqualsAndHashCode for JPA entities #5

@Evegen55

Description

@Evegen55

Hi!
Recently our company purchased your great book but I've noticed one thing. Annotation @DaTa also will generate equals() and hashCode() methods which include all fields - with mapped collections too.

For instance, please see an example https://github.com/cloud-native-java/data/blob/master/jpa/src/main/java/demo/account/Account.java

There can be LazyInitializationException thrown by Hibernate if there is no Session. I've also noticed that mapped collections annotated with FetchType.EAGER - which is not a good idea for consuming memory. It would be great if this behavior changed so code will looks more production-ready.

Also I could do this as pull request.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions