0
2つのJPAエンティティクラスによって拡張された以下の基本エンティティクラスがあります。JPA entityManager.createNativeQuery()を使用した更新クエリの@PreUpdate
@MappedSuperclass
public class BaseEntity implements Serializable {
...
...
@PrePersist
protected void onCreate() {
this.modifiedOn = new Date();
}
@PreUpdate
protected void onUpdate() {
this.modifiedOn = new Date();
}
}
ここで、エンティティマネージャを使用して以下のネイティブクエリコールを使用していくつかの列を更新するとします。それはと呼ばれますか?私たちは、エンティティマネージャを使用しているが、更新がネイティブクエリのために解雇された場合、それのような
Query query = super.getEntityManager(Constant.PSUNIT).createNativeQuery("UPDATE CUSTOMER SET TYPE = 'XYZ' WHERE SOURCE = 'ABC'");
query.executeUpdate();
@Entity
@Table(name = "CUSTOMER")
public class Customer extends CustomerSuper {
// customer related fields. and getting setter with annotations.
...
...
...
}
@MappedSuperclass
public class CustomerSuper extends BaseEntity implements Serializable {