ehsan shirzadi
ehsan shirzadi

Reputation: 4859

What is IsNull in HQL?

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

Upvotes: 5

Views: 6588

Answers (1)

cнŝdk
cнŝdk

Reputation: 32175

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.

Upvotes: 7

Related Questions