Hibernate 6.2 JPQL statement and specify inline parameters types

So I have a number of statements where “where” clause has inline parameter assignment
something like

UPDATE EntityC c SET c.cName='N' and c.variableParameter=:p1 WHERE c.something=:p2

in my entity EntityC cName declared as java.lang.Character
and now hibernate complains

java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: The assignment expression type [java.lang.String] did not match the assignment path type [java.lang.Character] for the path c.cName

so it treats ‘N’ in jpql as string. is there easy way to let it know that ‘N’ is character and not string ?
I tried cast(‘N’ as java.lang.Character) and it worked, is there a “lighter” way to do that ? Something like 'N’c or some “magic quotes” that will be parsed as char ? Like something that will be easy to use for find & replace editor feature ?
Giving that I have a number of places it will take some time to replace, unless I’ll find some way to automate that…

You found a bug :slight_smile:
We’d very much appreciate if you could create an issue in the issue tracker(https://hibernate.atlassian.net) and attach a test case(hibernate-test-case-templates/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

Thanks,
create the issue: [HHH-16818] - Hibernate JIRA

1 Like