java - Hibernate: How to set NULL query-parameter value with HQL? -
How can I set the hibernate parameter to "blank"? Example:
query query = getSession (). CreateQuery ("country", "cadence", "hierarchy", "type", type, hibernate, etc.); CreateQuery ("countryDTO c to c.status =: condition and c.type =: type") .setParameter ("position", position, hibernate).
In my case, the status string can be zero. I have debug it and it comes in hibernation, so this creates a SQL string / query like this .... status = null
... although this does not work in MYSQL, SQL statement should be " the status is zero
" (MySQL does not understand the status = empty and considers it to be incorrect so that no record will return to the query, by the MacSQL docs I have read ...)
My question:
-
Why not < Code> Hibernate is "empty" to translate a null string correctly (and rather, "incorrectly" creates "blank")?
-
What is the best way to rewrite this query, so that it is nil-safe? With zero, I mean, in this case that the "status" string is zero, should it be "empty"?
Thanks a lot!
-
I believe the first Hibernate SQL translates its HQL query And then only it tries to force your parameters. Does it mean that this
param =?
tothe ultimate null
-
will not be able to retype the query. Benchmark API usage:
criteria c = session. Creation classification (country). C.add (restriction. Eq ("type", type)); C.add (status == blank restrictions .isNull ("status"): restriction. Eq ("status", position)); List Result = c.list ();
Comments
Post a Comment