问题
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 :MOED"),
Error: Parameter value [2011] was not matching type [java.lang.Integer]
Environment is Spring w Hibernate/JQL + SQL Server
回答1:
I had a similar problem and could fix it this way:
I used long instead of int as a type for the respective field.
来源:https://stackoverflow.com/questions/6622882/hibernate-parameter-value-2011-was-not-matching-type-java-lang-integer-ho