5

How to write an HQL query like this SQL Query?

SELECT IsNull(name, '') FROM users

When I search for HQL IsNull, All results are for IS NULL or IS NOT NULL

cнŝdk
  • 31,391
  • 7
  • 56
  • 78
ehsan shirzadi
  • 4,709
  • 16
  • 69
  • 112

1 Answers1

7

If you check the Hibernate documentation you can see that they provide many useful expressions for such statements, you can check the CASE expressions section where it says that you can use coalesce() expression instead of ISNull().

So your query will be:

SELECT coalesce(name, '') FROM users

You can check their Simple case expression example for further details.

cнŝdk
  • 31,391
  • 7
  • 56
  • 78