Hi,all I am experiencing the JPA 2.0 new features using openjpa 2.0,but currently I was trapped. I defined a entity class Student @Entity public class Student implements Serializable { @Id private Integer id; ... private double totalScore; private String rank; //getters and setters } When I tried to simply update the rank,it all works fine. public void updateRank(Integer id) { String jpql="UPDATE Student s " + "SET s.rank= 'F' " + " WHERE s.id = " + id; Query query = em.createQuery(jpql); query.executeUpdate(); }
but when I tried to update the rank according to totalScore in the following method.
public void updateRank(Integer id) { String jpql = "UPDATE Student s " + "SET s.rank= " + " CASE WHEN s.totalScore<20 Then 'D' " + " WHEN s.totalScore>=20 AND s.totalScore<30 Then 'C' " + " WHEN s.totalScore>=30 AND s.totalScore<40 Then 'B' " + " WHEN s.totalScore>=40 AND s.totalScore<50 Then 'A' " + " Else 'N/A' " + " END " + " WHERE s.id = " + id; Query query = em.createQuery(jpql); query.executeUpdate(); }