https://kotlinlang.org logo
#server
Title
# server
ł

Łukasz Pięta

02/16/2023, 12:30 PM
Hi 👋 What do you think about making a JPA entity
data class
? I know that equals and hashcode need to be overridden then, but what about "The entity class must not be final*"* rule from JPA Specification? It can be easily solved by all-open compiler plugin as well. However it looks weird in the bytecode
Copy code
@javax.persistence.Entity public open data class
I already found an issue https://youtrack.jetbrains.com/issue/KT-34568/All-open-plugin-does-not-support-data-classes and the answer
breaking
data class
contracts will eventually bring more harm than good.
but I wonder what are the exact consequences of breaking the
data class
contract
j

Jonas TM

02/16/2023, 1:06 PM
Have a look at this webinar from yesterday. It also covers data class and JPA

https://www.youtube.com/watch?v=cjpSaeIfq9M

👍🏾 1
👍 1
ł

Łukasz Pięta

02/17/2023, 9:33 AM
@Jonas TM Thanks for the link! However it wast just said "not to use
data class
for `@Entity`", but no further analysis was made 😕 I already knew that
data class
causes problems to the JPA and there is a more detailed video from jetbrains explaining that further

https://www.youtube.com/watch?v=a_6V8xwiv04&ab_channel=KotlinbyJetBrains

but still I don't know what might be the consequences of breaking the
data class
contract in bytecode, even though I know there is no sense to use
data class
for entity at all
8 Views