views:

15

answers:

0

Hi,

I have three entities in my system - one of which must be updated when fields on the other two are changed:

@Entity
public class Order {
    private String name;
    private Integer quantity;
    private String status;
}

@Entity
public class OrderLocation {
    private String status;
    private String desc;
}

@Entity 
public class OrderKey {
    private String generatedKey;
}

So after any field on Order or OrderLocation are changed, I have to regenerate the key (in code), then save it back to OrderKey.

I've been looking at EntityListeners to do this, but unsure of whether to use JPA, or Hibernate versions. I'd like to use annotations ideally.

Any guidance would be much appreciated - thanks in advance.