siamackj wrote:
When I change the generator class to "uuid.string" and change the id type in my database to varchar, everything works !!! Does anyone know why generator class "native" does not work !!! I am using WSAD5.1.2 & DB2 8.1.
Yes, because if you want to use native, then you have to set up your table in DB2 to automatically generate the ID for you. This is done using the IDENTITY keyword, e.g.
create table table1 (c1 varchar(30),
c2 int generated by default as identity,
c3 decimal(7,2),
c4 char(1))
In MySQL, its the same idea, but you use the AUTO_INCREMENT keyword.
The reason why your change worked was because the uuid.string generator class is essentially delegating the id generation to hibernate, rather than DB2 (native).
Normally its pretty unlikely that you are going to get a free reign in changing the type of an ID field on an existing database, so you are better off altering exisiting tables to add on the identity attribute to a column, rather than changing the column type as you have done.