could not bind value to parameter
I'm running a query in Java using HQL and creating a parameter that looks like this:
query.setParameter("month", month);
The month variable is a BigDecimal that is between 1 and 12. However, the month variable was passed to the function running this query as an Object. So when it is being set as a parameter it is seen as an Object.
When I run the query I get this error:
15:46:48,878 INFO [IntegerType] could not bind value '4' to parameter: 1; java.math.BigDecimal
15:46:48,878 ERROR [STDERR] java.lang.ClassCastException: java.math.BigDecimal
15:46:48,878 ERROR [STDERR] at org.hibernate.type.I开发者_开发问答ntegerType.set(IntegerType.java:41)
15:46:48,878 ERROR [STDERR] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
15:46:48,879 ERROR [STDERR] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
15:46:48,879 ERROR [STDERR] at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:38)
The '4' is the value stored in my month variable. So it's obviously something wrong with that parameter. What could possibly be causing this?
I fixed it. It was just a problem trying to add a BigDecimal to a constant number within the query.
精彩评论