问问题
1905 次
1 回答
1
实体管理器不喜欢您的 String 参数。
Caused by: java.lang.IllegalArgumentException: You have provided an
instance of an incorrect PK class for this find operation. Class
expected : class java.lang.Integer, Class received : class
java.lang.String.
实体管理器的 find 方法搜索具有给定 id 的实体或从具有给定 PK 的 db 视图中搜索实体。我认为您有这样的 Book 实体:
@Entity
public class Book {
@Id
private Integer isbn;
....
所以你必须将一个整数传递给 find 方法。
em.find(Integer.parseInt(isbn)) //just a hack
我希望这对你有帮助。
于 2012-04-04T07:13:54.613 回答