java - 持久性错误消息 : An instance of a null PK has been incorrectly provided for the find operation

标签 java jsf jpa netbeans

我正在尝试使用 Netbeans 7.01 来遵循有关 JSF 2.0 和 JPA 的教程。我正在使用 oracle XE 和 JDBC_6。我使用实体向导中的 JSF 页面来生成我的 JSF 页面。一切正常,因为我可以从数据库中检索数据并显示它们。但是,当我尝试在数据库中创建或更新记录时,出现此错误:

An instance of a null PK has been incorrectly provided for the find operation

这是怎么引起的,我该如何解决?

最佳答案

这基本上意味着您执行了以下操作:

Entity entity = em.find(Entity.class, null);

注意这里PK是null。要解决您的问题,只需确保它不是 null

关于java - 持久性错误消息 : An instance of a null PK has been incorrectly provided for the find operation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301107/

相关文章:

java - 尽管 key 存在并且相同,为什么 containsKey(String) 在我的程序中返回 false?

java - 对目录中的所有文件执行操作

jsf - 如何使用 JSF/Primefaces 使两个字段中的一个至少为必填字段

java - 将数据库 column1、column2、column 映射到元素集合

java - hibernate/JPA : Is it possible to Override @Id field?

java - 发送完所有未决消息后关闭套接字

java - Heroku 无法检测到构建包 - Spring Boot

jsf - 自定义 FacesServlet <url-pattern> 去掉 .xhtml 扩展名

jsf - 在扩展现有 JSF 组件的复合组件中继承组件属性

java - 加入列的 Hibernate 合并问题