Using Kotlin "data class" in bi-directional JPA relations

Data classes in Kotlin provide an easy way to implement entity beans for JPA without a lot of boilerplate code. This also includes toString(), hashCode() and equals() methods. However when you are modelling a bi-directional relationship between to entities you run into trouble since the toString() methods of both entities will call each other recursively ending in a StackOverflowException eventually. @Entity data class Child( @Id @GeneratedValue val id: Long? = null, val name: String, @ManyToOne val parent: Parent?
Read more

[100 Days of Code] Day 056: June 7, 2017

Today’s Progress: I have been fighting with eclipse link the whole time. Suddenly my integration tests that where using JPA did stop working. Finally I decided to switch to Hibernate which solved my problems. Things I’ve learned: I will be using Hibernate from now on whenever possible. Things I’ve planned for tomorrow: Continue to publish the whole dependency chain so I can continue with my CD pipeline. Link(s) to work: rules-jpa