posted 9 years ago
I'm using Spring Data JPA with Hibernate.
I have a class with a composite key mapped to a database table.
When I perform a save operation using the JPARepository extended interface object, I see the following log in the console:
This is what I see when i repeat the operation with the same data:
It appears Spring Data first checks whether the Key exists in the database, and then proceeds to perform insertion.
There should be a way to catch the information which hibernate has found (that the database entry/key exists in the database)? How can we check that? There should be some kind of information which would be possible to get from Spring that it would return/give in any other way to the application- if it is not going to go ahead with insertion in the event of a duplicate entry. (Spring makes a decision (based on some information) not to insert after finding an existing primary key.)