Question

I am new to Hibernate and am trying to figure out how to let Hibernate figure out whether an INSERT or UPDATE is appropriate, based on whether or not the object already exists in the underlying DB.

I was hoping to see a Session#createOrUpdate(...) method (or something similar) but don't see any (although I do see an interesting method called persist(...).

So I ask: how can I tell Hibernate "hey, here's a User object; if it doesn't exist then INSERT it, and if it does exist, then UPDATE it"? Thanks in advance!

Was it helpful?

Solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top