hibernate Native SQL Queries Example to get a unique result


Object pollAnswered = getCurrentSession().createSQLQuery(
        "select * from TJ_ANSWERED_ASW where pol_id = "+pollId+" and prf_log = '"+logid+"'").uniqueResult();

with this query, you get a unique result when you know the result of the query is always going to be unique.

And if the query returns more than one value, you will get an exception


You also check the details in this link here with more discription

So, please be sure that you know the query will return unique result