Tooling that supports correct mapping of bidirectional JPA relations

69 views Asked by At

I have multiple JPA (Hibernate) persisted @OneToMany and @OneToOne relationships in my project that are not held consistent by their setters and adders methods as discussed here. Now I need to refactor these relationships to programmatically keep consistency in place at all times. Do static code analyses / generic unit tests or other tools exist to support me with this task?

1

There are 1 answers

0
Mikita Herasiutsin On

On my project we use integration spring tests with H2(Java SQL database). It allows to find bugs even with relations between entities. There is a SpringRunner for JUnit which load application context so you can test your application almost as real environment. You can find more information here https://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html