JPA optimistic lock - setting @Version to entity class cause query to include VERSION as column
- by masato-san
I'm using JPA Toplink Essential, Netbean6.8, GlassFish v3
In my Entity class I added @Version annotation to enable optimistic locking at transaction commit however after I added the annotation, my query started including VERSION as column thus throwing SQL exception.
None of this is mentioned in any tutorial I've seen so far. What could be wrong?
Snippet
public class MasatosanTest2 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Column(name = "username")
private String username;
@Column(name = "note")
private String note;
//here adding Version
@Version
int version;
query used:
SELECT m FROM MasatosanTest2 m
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException
Call: SELECT id, username, note, VERSION FROM MasatosanTest2