当我在JPA中编码时,我发现此错误说“查询类型的方法getLong()未定义”请帮我解决这个问题。
public long getErrorid(String errDesc)
{long errorid=0;
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("wqs-poc"); System.out.println("EntityManager Factory created successfully !!!");
EntityManager em = entityManagerFactory.createEntityManager();
System.out.println("eNTITYmANAGER CREATED SUCCESSFLLY !!!"); Query query = em.createNativeQuery("SELECT errorid FROM wqsd.error_master WHERE errdsesc = "+errorid); errorid = (long)query.getLong();
System.out.println("errorid= "+errorid);
return errorid;}
答案 0 :(得分:0)
错误告诉您没有为javax.persistence.Query
接口定义getLong()。也许你的意思是:
errorid = (Long)query.getSingleResult()[0];