我最近对我的 JPA 实体进行了 F-ed,并且我正在拼命地尝试恢复该功能。向我的实体添加一些默认查询后,我无法在会话 bean 中调用它们......我收到了这个异常
There is no query with the name "" defined for any of the known persistent classes:
虽然上述命名查询确实存在,但它只是对持久性类(或实体 bean)的注释。我需要将其添加到 ORM.xml 文件中吗?我似乎记得您可以对 ORM.xml 文件进行注释,也可以直接对实体 bean 进行注释。我在这里错过了一步吗?
谢谢。
更新:实际命名查询:
import javax.persistence.Table;
import javax.persistence.NamedQuery;
import javax.persistence.NamedQueries;
@Entity
@Table(name="EMAIL_DOMAIN_TRUST")
@NamedQueries({
@NamedQuery(name="getEmailDomainTrust", query = "SELECT e FROM EmailDomainTrust e"),
...
})
这是我在无状态会话 bean 中调用它的地方
public List<EmailDomainTrust> getEmailDomains() {
List listOfEmailDomains = null;
//try
//{
System.out.println("Testing 1..2...3...!");
listOfEmailDomains = emf.createNamedQuery("getEmailDomainTrust").getResultList();
System.out.println(listOfEmailDomains.size());
//}
//catch(Exception e)
//{
//System.out.println("Sugar Cookies! This thing doesn't work");
//}
// while(it)
return listOfEmailDomains;
}
不知道为什么好像找不到?我在 Websphere 集成开发人员工作。也许有些东西没有正确更新?