I'm getting Null Pointer Exception while retrieving Primary Key or Id of an Entity in Hibernate result query. The Primary Key value is simply a long value. 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 c.id from ccy c where c.name='sowndhar' ";
Query query = session.createQuery(HQL);
ID = (Long)query.uniqueResult(); //getting NullPointerException in this line
return ID;
Any suggestions plz? Any help would be much appreciated
select id from samplereturn an Long, I would guess that it returns a List of Longs, or du you only have 1 entry in your database?