Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Hibernate は、一意のフィールドを持つテーブルに挿入する必要があります。プログラムの実行を継続できるように、重複するエントリを無視したいと考えています。MySQL では単に と言うだけINSERT IGNOREですが、Hibernate でそれを行う方法がわかりません。助言がありますか?ありがとう!
INSERT IGNORE
単純な SQL クエリを使用している場合は、次のコードを使用します。
Query query = session.createSQLQuery("INSERT IGNORE INTO user (name,username) VALUES (:name,:username)"); query.setParameter("name", name); query.setParameter("username", username); int i= query.executeUpdate();