users@glassfish.java.net

Re: Problem with the key type with findById

From: Youness <youness126_at_gmail.com>
Date: Sat, 13 Mar 2010 19:38:07 +0330

The error indicates:
incorrect PK class for this find operation. Class expected : class
java.lang.Integer, Class received : class java.lang.Long.
This means the "id" you pass to method "em.find(ejb.Customer.class, id);" is
type Long and it must be type Integer.
Try fixing that by casting or change the pk of your entity to Long type.
As I said earlier, for simplicity, try using
"Customer.class" in your method and import the class "Customer" instead.