Hi,

do you use attribute access="readonly" in the
field descriptor of your identity fields?

e.g.
<field-descriptor
        name="identifier"
        column="NATIVE_ID"
        jdbc-type="BIGINT"
        primarykey="true"
        autoincrement="true"
        access="readonly"
        />

regards,
Armin

----- Original Message -----
From: "shivaken" <[EMAIL PROTECTED]>
To: "'OJB Users List'" <[EMAIL PROTECTED]>
Sent: Thursday, July 24, 2003 4:55 AM
Subject: SequenceManager{Native|MySQL}Impl has a problem.


> 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]
>
>
>



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

Reply via email to