class cast exception in ejbLoad()

Discussions

EJB programming & troubleshooting: class cast exception in ejbLoad()

  1. class cast exception in ejbLoad() (1 messages)

    ClassCastException is thrown inside ejbLoad() in my entity bean. code that threw the exception: Occupation occupation= (Occupation)ctx.getPrimaryKey(); Occupation is primary key class(occupationId is an int field). when i replaced Occupation with Integer, as below, no exception was thrown. Integer primaryKey = (Integer)ctx.getPrimaryKey(); 1.why getPrimaryKey() is not returning primary key class? 2.what getPrimaryKey() actually does? have a great day, krishna prasad g
  2. Try using EntityContext.getEjbObject().getPrimaryKey(). Result may depend on whether you have compound primary key, and on application server used.