I have the below classes defined,
@Entity
@Idclass(Key.class)
public void ClassA {
...
@Id
@Version
private long version;
...
}
public class Key {
...
private long version;
...
}
When compiling i get the below error,
“Unable to define @Version on an embedded class”
So is it possible to have a property which is part of the composite key defined as above also have the @Version. I did try adding the @version to the property in the Id class itself, but still it didn’t work.
thx in advance
It doesn’t make sense. The point of
@Versionis to define a field that the JPA engine will increment at each modification of the entity. The point of@Idis to define the primary key, which should be unique and immutable, and be used to identify an entity for its whole life. The@Versionfield should thus not be part of an ID.