I'm getting Null Pointer Exception while retrieving Primary Key or Id of an Entity in Hibernate result query.
My Entity class:
@Entity
@Table(name="sample")
public class ccy{
@Id
@column(name = "S_ID")
private long id;
2nd varibale and so on
when i write hibernate query to retrieve it causes Null pointer exception, my select query is:
long ID = 0;
String HQL = "select id from sample";
Query query = session.createQuery(HQL);
ID = (Long)query.uniqueResult(); //getting NullPointerException in this line
return ID;
Any suggestions to avoid this exception? I'm stuck here. Any help would be much appreciated