Jpa / hibernate和Postgres新手问题在这里。
我有一个这样定义的数据库实体:
public class accountEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "account_number",nullable = false)
private String accountNumber;
.... few other columns including createdAt,updatedAt and few other account related fields
}
在我的代码中,使用JpaRepository,我想执行以下操作:
accountEntity acc = new accountEntity();
acc.setaccountNumber(123);
accountRepository.upsert(acc)
我知道我需要为类似的事情定义自己的sql 如果已经存在具有指定accountNumber的帐户,那么执行upsert的正确sql是什么(我将需要更新大多数字段,但不更新createdAt字段) 另外,关于批量更新的类似问题