Wednesday, January 13, 2010

Avoid Openjpa deadlock

Order and OrderPayment is one to many.

        @OneToMany(targetEntity = OrderPaymentImpl.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@ElementJoinColumn(name = ORDER_UID, nullable = false, updatable = false)
public Set getOrderPayments() {
return this.orderPayments;

nullable=false, updatable=false means the field in table OrderPayment should not be null, should not be updated when the order is updated. Without this on foreign key may cause dead lock on database.

No comments:

Post a Comment