0

当我在 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;}
4

1 回答 1

0

该错误告诉您 getLong() 没有为javax.persistence.Query接口定义。也许你的意思是:

errorid = (Long)query.getSingleResult()[0];
于 2013-03-26T19:42:02.637 回答