1 Reply Latest reply on Feb 22, 2002 7:34 AM by Tim

    using database auto increment, with cmp 2.0

    Tim Newbie

      Hi,

      currently I see there is no neat way of creating an auto-incremented primary key in JBoss. This not too much of a problem because I can add one manually to the database. It is not an ideal solution but one I am willing to live with for the moment.

      However, I am having some problems. If I leave out entering in the primary key field during ejbCreate, the database complains about having the field being set to "NULL". Even if I set the field in the database to allow "null" entries, JBoss still catches it. Fair enough, but I would like to know how to create an entity bean without trying to set the primary key at all and let the database handle it. Is there a way?

      I guess the problem is that the ejb container would then have to reread this value to be properly synchronized. I've seen the solution of using a separate ejb to handle auto incrementing but I'd prefer to stay away from that if possible.

      Many thanks,

      Tim