开发者

CMP 2.0 bean auto-generated primary key WAS 6.1

is it possible to map bean's key field with identity primary key column in DB2? Sample table: CREATE TABLE ADDRESS ( ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 NO CYCLE CACHE 20 NO ORDER ), Line1 VARCHAR(255) NOT NULL, Line2 VARCHAR(255), City VARCHAR(255) NOT NULL, Postcode VARCHAR(6) NOT NULL, Country VARCHAR(50) NOT NULL, Latitude DOUBLE, Longitude DOUBLE ) AUDIT NONE DATA CAPTURE NONE CCSID UNICODE;

ejbCreate methods have been tailored NOT TO set ID field, but it gets initialized with default for integer type - 0 so i'开发者_如何学JAVAm getting DuplicateKeyException on second and following calls to ejbCreate. What is the best way to implement IDENTITY behavior? I found many examples for JBoss but nothing for WAS. It was easy with JPA, but CMP 2.0 is a must at this time


Override method ejbPostCreate. You will be able to retrieve the generated ID from there, and update your model and your code in order to avoid duplicate IDs.

For instance, take a look at http://forums.sun.com/thread.jspa?threadID=699131

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜