在使用JEE多年之后,我目前正在实现我的第一个spring boot应用程序。 我想知道JPA / Hibernate的行为。现在使用CrudRepository时,只有在显式地调用save()时,更改才会存储到数据库中。我的CrudRepository: public interface UserAccountRepository extends CrudRepository<UserAccount, Long> {//Stop here in JEE
我想强制CrudRepository#save( entity )插入一个新的实体,而不是在主键已经存在的情况下首先选择实体并更新它。= new Lock(id);repo.save(firstLock);发生的情况是,第一个保存操作执行以下两个语句Hibernate: select lock0_.uuid as uuid5_0_, lock0_.expires as expires5_0_ from lock