开发者

Problem Migrating a ntive query from Hibernate to EclipseLink 2.0

I'll appreciate if anyone can point me to a solution as to why I could be getting the error below in an attempt to execute the following query which caused no problem whatsoever with Hibernate:

The Entity (Step.java):

@Entity
@Table(name = "IAS_STEP")
public class Step implements Serializable {
    @Id
    private Long id;

    @Temporal(TemporalType.DATE)
    private Date tarih;

    private long formId;

    private Byte faz;

    // getters, setters, etc.
}

The method in the controller class:

public byte getMaxPhase(String sid, long form_id) {
    EntityManager em = getEntityManager();
    try {
        Query q = em
                .createQuery(
                        "select max(faz) as mf from Step s where s.id = :sid and s.formId = :formId")
                .setParameter("sid", sid)
                .setParameter("formId", form_id);
        return ((Byte) q.getSingleResult()).byteValue();
    } finally {
        em.close();
    }
}

This worked just fine in Hibernate, but ca开发者_开发技巧uses an error in EclipseLink 2.0.

Anyone can suggest a workaround?


max(faz) 

should be,

max(s.faz)

(an you are executing JPQL not a native SQL query)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜