In Hibernate query how do i check if a property is null? Depending on the result i want to fetch that property and if it is not null i have to fetch another property.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Following two ways are valid HQL queries and both are also valid JPA 2.0 JPQL queries.
Using coalesce (returns first non-null, or null if both are null):
Equivalent select-case, which is bit longer: