Hi,

I was started to use SequenceManagerNativeImpl to use autoincremented value.
# And I am evaluating both that and SequenceManagerMySQLImpl.

But, That has a problem. My app's junit test failed.
I couldn't understand the problem.

The cause seems to be afterStore(...) of them(MySQLImpl and NativeImpl) 
updates stored object's autoIncrement field.

When store(obj) inserted obj, That is proper.
But when store(obj) updates obj, That is not proper.
afterStore(...) should not update autoincrement field.

Anyway, I want to write a patch for this.

To fix this, SequenceManage has to update autoIncrement field only when
autoincremented by DB.
the value must be autoIncremented when inserted.

There are 2 way to know that.

1 .
boolean isAutoIncremented(Object obj, ClassDescriptor cld) {
    return isInserted(obj, cld);
}

boolean isInserted(Object obj, ClassDescriptor cld) {
    return  !(jdbcAccess.materializedObject(cld, oid)) != obj);
   // If so, obj must be inserted.
}

2.
boolean isAutoIncremented(Object obj, ClassDescriptor cld) {

   FieldDescriptor fd = cld.getAutoIncrementField();
   Object value = fd.getPersistentField().get(obj);

   return (value == getUniqueValue(fd));

   // If so, value must be autoincremented.
   // SequenceManageMySQLImpl getUniqueValue( int filed ) returns 0
   // SequenceManageNativeImpl getUniqueValue( int filed ) returns -1
}

-- 
-- shivaken
antshell: Ant command line front end
http://www.antshell.org


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

Reply via email to