Skip to content
Advertisement

Strange exception when mapping two columns in a table to the same column in another table

There are two entities:

JavaScript

and

JavaScript

when i create repository with custom query

JavaScript

the exception is thrown

JavaScript

but if i remove the second referencing column from the query

JavaScript

the program starts without exceptions.

Moreover, if i use standart query method bookRepository.findAll():

JavaScript

all works fine

Books: Book{id=3, name=’Test book’, author=Person{id=1, name=’Person A’}, reviewer=Person{id=2, name=’Person B’}} Book{id=4, name=’Test book’, author=Person{id=2, name=’Person B’}, reviewer=Person{id=1, name=’Person A’}}

Advertisement

Answer

Replace this:

JavaScript

with below (Use aliases)

JavaScript
Advertisement