0

I am wondering if domain version will be changed if oneToMany relation is updated. e.g There is User entity which has OneToMany relation to Addresses . So if I am updating Addresses list will it have impact on user version ?

@Entity public class User {
    @Id @Column(name = "id") 
    @GeneratedValue 
    private Long id; 

    @OneToMany (mappedBy = "document") 
    public Set<Addresses> userAddresses; 

    @Version @Column(name="OPTLOCK") 
    public Integer getVersion() { ... } 
}
C1pher
  • 1,933
  • 6
  • 33
  • 52
  • Could you please post the code and the definition of the tables `User` and `Addresses` that you are working on? – Kirby Aug 03 '15 at 16:13
  • I don`t have code , I was asked this question during interview. Just Imagine there is @Entity public class User{ @Id @Column(name = "id") @GeneratedValue private Long id; @OneToMany (mappedBy = "document") public Set userAddresses; @Version @Column(name="OPTLOCK") public Integer getVersion() { ... } } – Kolomolobolo Aug 03 '15 at 17:08

1 Answers1

0

No, it will not have any impact on the parent's version. You should explicitly force the parent version increment; see LockModeType.OPTIMISTIC_FORCE_INCREMENT.

Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110