I am having Null Pointer Exception while using the following code.
List<Object> = getSession().createSQLQuery(sqlQueryString)
.setResultTransformer(Transformers.aliasToBean(Target.class)).list();
I have seen this question for reference: https://stackoverflow.com/questions/5386648/non-managed-entity-in-hibernate, But it is not useful for me, Because the query result does not have any null values. So i unable to find what is wrong with my code. Can anyone solve this?
Thanks in advance.
.addScalar("fieldName", requiredDatatype) method will fix this problem. The following code will explain to you.
List<Object> = getSession().createSQLQuery(sqlQueryString)
.addScalar("field_1", Hibernate.INTEGER).addScalar("field_2", Hibernate.INTEGER) .........addScalar("field_n", Hibernate.INTEGER)
.setResultTransformer(Transformers.aliasToBean(Target.class)).list();