Force Hibernate Insert Without Select Statements

前端 未结 3 1058
孤城傲影
孤城傲影 2020-12-06 17:44

I am attempting to insert a new record into a table that I know is unique before hand. I have tried calling save() on the object, but that does a bunch of SELECT statements

3条回答
  •  一个人的身影
    2020-12-06 18:47

    Hibernate is trying to determine if the object is transient or not, so is performing a SELECT before INSERT. You might be able to adapt this answer from Hibernate OneToOne mapping executes select statement before insert; not sure why to avoid the SELECT.

    Or, I remember a post in a forum about overriding the version column that hibernate uses in the transient check (and for optimistic locking). I'll edit this answer when I find it.

提交回复
热议问题