EJB programming & troubleshooting: class cast exception in ejbLoad()
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
- Posted by: krishna prasad
- Posted on: August 07 2008 03:54 EDT
Try using EntityContext.getEjbObject().getPrimaryKey(). Result may depend on whether you have compound primary key, and on application server used.