开发者

Hibernate - Parameter value [2011] was not matching type [java.lang.Integer]. How to solve?

I am getting the message above even though the value I'm passing through an Integer to the named query. Can anyone explain why? Thanks

DAO Java Code

Calendar cal = Calendar.getInstance();
cal.setTime(interval.getStartDate());        
query.setParameter("academicYear", new Integer(cal.get(Calendar.YEAR)));

Query:

@NamedQuery(name = "StudentDemographics.findByMOEDEqual", query = "SELECT s.student FROM StudentDemographics s " +
            "WHERE :academicYear = s.academicYear " +
            "AND UPPER(s.MOED) like :MOE开发者_StackOverflowD"),

Error: Parameter value [2011] was not matching type [java.lang.Integer]

Environment is Spring w Hibernate/JQL + SQL Server


I had a similar problem and could fix it this way:

I used long instead of int as a type for the respective field.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜