Hello Armin and Martin,

I am not using external seuence. I build a ID generator for it. And I am here using primitive bigint for PK and FK without autoincrement setting.

I change a little bit and get the approch:

broker.store(department, ObjectModificationDefaultImpl.UPDATE);


Thanks for your replay, Wallace


Martin I. Levi wrote:


Hello Wallace,

We had a similar problem here and it had to do with OJB's automatic
increment feature.


Are you using a external sequence? if that is the case check you dont
have autoincrement set to true.

Hope it helps.

Greets,


Martin Ivan Levi


Universitat Politecnica de Catalunya
Centre Tecnologic de Transferencia de Calor


On Tue, 2004-04-27 at 06:00, Info wrote:


Hello,

I am using following code to update a record:

broker =


PersistenceBrokerFactory.defaultPersistenceBroker();


QueryByCriteria query = new QueryByCriteria(department);
DepartmentDto result = (DepartmentDto) broker.getObjectByQuery(query);
if (result != null){
result.setDescription(department.getDescription());
result.setName(department.getName());
broker.beginTransaction();
broker.store(result);
broker.commitTransaction();
}


but I get Exception:

*org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure


while

insert object data for class com.zousys.silique.dto.DepartmentDto, PK


of

the given object is [ departmentId=0], object was [EMAIL PROTECTED], exception message is [Invalid argument value, message from server: "Duplicate entry '0' for
key 1"]


*From online document, I read that OJB will check if the PK exist, if yes, OJB will update the record. Anyone know why I get this error?

Thanks a lot!

Wallace

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to