I wonder, if there is any definition by JPA for the behavior, if you setting equals value for any property. I didn't find any words in the specification.
I've tested with TopLink Essentials and Hibernate, what happens if I load a entity from database and set the property with same value again.
@Entity
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(length = 20)
private String value;
@Version
private long version;
// Define setter and getter...
}
Setting the same value with
entity.setValue(new String(myChars));
does not change the version value.
Can I expect this behavior for every implementation. I don't think so...