I have this code
@Column(updatable=false)
@Enumerated(EnumType.STRING)
private ExamType examType;
However, I can still change the value when I update it via merge. Why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ok. First, if you want the
examTypecolumn to be included inSQL UPDATEstatements, you shouldn’t mark it withupdatable=false. That being said, it appears thatupdatable=falseis ignored when not used in combination withinsertable=falsebut that’s a bug in EclipseLink (Bug 243301), that’s not what JPA says. Set it totrueor remove it.Secondly, with the following entity:
The following test method just runs fine with EclipseLink:
Below the generated SQL statements:
INSERT INTO ENTITYWITHENUM (ID, EXAMTYPE) VALUES (?, ?) bind => [1, A] UPDATE ENTITYWITHENUM SET EXAMTYPE = ? WHERE (ID = ?) bind => [B, 1] SELECT ID, EXAMTYPE FROM ENTITYWITHENUM WHERE (ID = ?) bind => [1]Honestly, a bug on such an elementary thing in EclipseLink is very unlikely, more than a mistake on your side if I may 🙂
Update: After reading the comment from the OP, I think I got the question now (which was totally unclear to be honest): the OP actually doesn’t want the
examTypeto be updated which is the exact opposite of my initial understanding. So the OP is actually facing Bug 243301 (fix to be released in 2.0.2):Another workaround is described in Bug 294803 (that the previous one duplicates).