Could be caching issue. You can try one of these suggestions, see if the that help: Set the first-level and second level cache usage to false in the hibernate config file. Flushing and clearing the session after every insert.
Things that can help: Override the equal and/or hashCode method in the entity class.
Also to skip to procedure where you have to query the table every time you are inserting the data to see if it already exists, try overring the hashCode method in the entity class. create a hashCode based on some criteria using data you get when you populate the fields, and then setting that as the primary key, since the criteria will always produce the same hashCode if the data is same, at which point you can either skip it, give an exception, or simply update the record
|