Hi Armin, thanks for your response.

> thanks for the patch. Please, can you send me a patch for
> SequenceManagerNativeImpl (see CVS) too. Because
> I don't want to support SequenceManagerMySQLImpl
> any longer (to check your patch you can find a simple test case
> called NativeIdentifierTest). thanks.

Ok. I attached the patch for SequenceManagerNativeImpl.

Though I'm very suprised about you don't want to support 
SequenceManagerMySQLImpl.
I don't like SequenceManagerNativeImpl because 
SequenceManagerNativeImpl.getUniqueLong returns -1.
I really don't like that. And MySQL dosen't work properly with -1.

I want SequenceManagerNativeImpl to support init property to define
this value. That can be 0 or -1. And it must be depend on DB type.

Yesterday, I found another bug in SequenceManagerMySQLImpl.
MySQL returns long array SELECT LAST_INSERT_ID() query,
so getting new id takes long time when table has many records.
Just adding ' LIMIT 1 '  at the end fixes this performance problem.

regards,

-- shivaken
antshell: Ant command line front end
http://www.antshell.org
--- SequenceManagerNativeImpl.java.orig	2003-08-01 11:52:00.000000000 +0900
+++ SequenceManagerNativeImpl.java	2003-08-01 17:11:04.000000000 +0900
@@ -141,8 +141,15 @@
     public void afterStore(JdbcAccess dbAccess, ClassDescriptor cld, Object obj) throws SequenceManagerException
     {
         FieldDescriptor fd = cld.getAutoIncrementField();
-        long newId = getLastInsert(dbAccess, cld);
-        setFieldValue(obj, fd, new Long(newId));
+        if ((fd != null) && (isAutoIncremented(obj, fd)))
+        {  
+            long newId = getLastInsert(dbAccess, cld);
+            setFieldValue(obj, fd, new Long(newId));
+        }
+    }
+
+    private boolean isAutoIncremented(Object obj, FieldDescriptor fd) throws SequenceManagerException { 
+        return fd.getPersistentField().get(obj).equals(getUniqueValue(fd));
     }
 
 

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

Reply via email to