[ tokajac @ 29.04.2006. 16:16 ] @
I use the create method of EntityBean Avion on the next way: example: avionLocalHome = (AvionLocalHome)ctx.lookup("ejb/aero/AvionLocal"); AvionLocal avion1 = avionLocalHome.create("Boeing", "737",189); AvionLocal avion2 = avionLocalHome.create("McDonnell Douglas", "DC-10", 290); It creates apropirate AvionLocal objects only when database(MySql) is empty. When it's not, it raises: javax.ejb.DuplicateKeyException: Entity with primary key [.1.] alredy exists exception; primary key is generated with sequence counter: public AvionPK ejbCreate(String proizvodjac, String model, int kapacitet) throws CreateException { setAvionId(sequenceSession.getNextValue("Avion")); setProizvodjac(proizvodjac); setModel(model); setKapacitet(kapacitet); return null; } Does anybody know how can i write in the database when it's not empty(how can i generate the apropirate primary key)? |