Relative Content

Tag Archive for javaspring-bootspring-data-jpaorm

Spring Data JPA 2 interchangeable fields as id

In my Spring Boot backend I have and @Entity class for defining a connection between 2 systems, which will later be used for path finding algorithm.
For example, if search is by name=”A”, the results should be both leftSystem=”A” and rightSystem=”A”.
Generally, the idea is that entity with leftSystem=”A” and rightSystem=”B” should be the same entity as such with leftSystem=”B” and rightSystem=”A”.
I would like to ask for suggestions of how to implement such mappingsbehavior because the way I did it looks really bad.