I would like to implement something that I would call a conditional insert using Hibernate. So let's say I have an entity named A which maps to the corresponding table A. Before persiting a new Row to the table I want't to check if a certain row is already present and only insert the new one if it isn't. I also have multiple Clients who concurrently write to table A.
In my opinion I have to lock the entire table A before doing the check to prevent concurrent access by many clients.
So my question is how I would do this in Hibernate. Is it possible. Or am I wrong and there is maybe a completely different solution.