0

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
  • What's the type of academicYear field in the StudentDemographics? Commented Jul 8, 2011 at 10:18

1 Answer 1

3

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.