、基本的にオブジェクトが既にデータベースに存在するかどうかをチェックしてあるかの新しいインスタンスを保存し、必要にオブジェクトのいずれかの更新あなたはHibernateのsaveOrUpdate behaviorを複製することができます任意の方法、JPAでHibernateのsaveOrUpdateをどのように複製できますか? JPAでは
saveOrUpdate
public void saveOrUpdate(Object object)
throws HibernateException
Either save(Object) or update(Object) the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).
This operation cascades to associated instances if the association is mapped with cascade="save-update".
Parameters:
object - a transient or detached instance containing new or updated state
Throws:
HibernateException
See Also:
save(Object), update(Object)
がありますオブジェクト。
JPA transcationless読み取りは素晴らしいですが、私は実際にはこのメソッドがHibernateから欠落しています。経験豊富なJPA開発者はどのようにこれを処理しますか?
"プライマリキー"がヌルかどうかを確認するにはどうすればよいですか? –