문제

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!

도움이 되었습니까?

해결책

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top