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:

  1. Why not < Code> Hibernate is "empty" to translate a null string correctly (and rather, "incorrectly" creates "blank")?

  2. 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!

  1. 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 =? to the ultimate null

  2. 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

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -