| I have created a sample project to isolate an issue from a bigger project. In this project we have entities with composite keys: looks like the problem is related to using @IdClass with derived identities. Here is the repo with the failing test case: https://github.com/brunomendola/spring-jpa-composite-pk-with-relationships After saving 3 objects (which are correctly written to the database), the subsequent select for the same rows mixes up the JoinColumns and, forcing a flush, throws the following exception:
Since the cause is a HibernateException, I'm supposing it's a hibernate-core issue; correct me if I'm wrong. In the repo there are 2 more branches in which the test passes successfully, switching to @EmbeddedId or @IdClass with simple types. But I know it should work also with @IdClass and derived identities, since there are related tests in spring-data-jpa repository. I'm trying to map an existing database, so I don't have any freedom regarding the schema. Let me know if you need more info. Thank you! |