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]
