A
A
acwartz2021-08-16 18:11:49
Java
acwartz, 2021-08-16 18:11:49

Do Kotlin, lombok, and others follow the requirement that entity classes be identical?

I read the documentation here and find something strange: https ://docs.jboss.org/hibernate/orm/5.5/userguide...

equals and hashCode will return different values ​​for them.

However, hibernate has the concept of sessions and the Entity of the same record taken in different sessions (as you like) should always be the same:


So what's all the fuss? Normally, most Java objects provide a built-in equals() and hashCode() based on the object's identity, so each new object will be different from all others. This is generally what you want in ordinary Java programming. Conceptually, however, this starts to break down when you start to think about the possibility of multiple instances of a class representing the same data.


And therefore the question is: how are Kotlin and Lombok friendly with this, relieving us of boilerplate code in data (@Data) classes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-08-16
@acwartz

Of course they know about it and override equals and hashCode correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question