开发者

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

开发者 https://www.devze.com 2023-03-18 18:03 出处:网络
I am getting the message above even though the value I\'m passing through an Integer to the named query.

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

精彩评论

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