By W.ZH Nov 2009
Issue: When you try to create a new record in the table, you alowys get “Can not insert null to the xxx_ID”, xxx_ID is your table’s primry key in fact, you have defined a sequence in the table for this primary key and in the top link, you have also set up the ID to use this sequence . But still the sequence not work to create the new id number for your call to DB.
Solve: we can see that in the Object persistEntity(Object entity) , new record is created by
Object newInstance = uow.registerNewObject(entity);
this registerNewObject will create the record and also create sequence for you, when it does not work, you can use these instead to devide the steps to two:
Object newInstance = uow.registerObject(entity);
assignSequenceNumbers will create a sequcce number after the obj is registered to the DB.
You can also use the getSessionFactory().getSharedSession().getNextSequenceNumberValue(class) to aquire the sequence number manually.