The problem's been solved.

In case anybody else runs into this, you just need to set all
instances of the "auto-update" and "auto-delete" attributes in
your repository_user.xml to false (or leave them out entirely)
when using ODMG (see the docs about repository.xml).

Eliot

On Thu, 3 Oct 2002 12:47:45 +0000
This idiot, Eliot <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I've got a class Category that is similar to the TreeGroup
> object used in the junit tests, in that it has a parent
> attribute of the same class as itself, Category, and it has a
> childs attribute that is a Vector containing Category objects.
> 
> I get problems when trying to write an instance of Category
> (rootCategory) to the database using ODMG in the following way:
>  
>  Transaction tx1 = odmg.newTransaction();
>  tx1.begin();
>  /*
>   *  rootCategory is a Category instance with child Categorys.
>   *  Each child Category has its own child Categorys too.
>   */
>  tx1.lock(rootCategory,tx1.WRITE);
>  tx1.commit();
> 
> This method works almost 100% in that rootCategory and its
> childs are written correctly to the database.  However I always
> get an SQLException thrown that complains about "Duplicate
> entry 'x' for key 1"  (where x is always the int id of the
> first child Category of the rootCategory).
> 
> (the exception output is at the end of the message)
> 
> I don't think that repostiory_user.xml for Category is the
> problem as everything works fine when using the
> PersistenceBroker API alone to store the rootCategory instance,
> like:
> 
>       broker.store(rootCategory);
> 
> Does anybody know whats causing this behaviour and how I might
> resolve this problem?
> 
> Thanks in advance,
> Eliot
> ------------
> Test output:
> -------------
> [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl]
> INFO: Already created persistence broker instances:
> 0[org.apache.ojb.broker.util.sequence.SequenceManagerFactory]
> INFO: Use sequence manager class: class
> org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl[or
> g.apache.ojb.broker.accesslayer.AbstractPoolableConnectionFact
> ory] INFO: # Create connection pool for JdbcDescriptorKey
> 1272749578
> #[org.apache.ojb.broker.accesslayer.AbstractConnectionFactory]
> INFO: # Already created connections: 1 returning :
> org.gjt.mm.mysql.jdbc2.Connection@3570b0[org.apache.ojb.broker
> .ta.PersistenceBrokerFactoryDefaultImpl] INFO: Already created
> persistence broker instances:
> 1[org.apache.ojb.broker.accesslayer.AbstractConnectionFactory]
> INFO: # Already created connections: 2 returning :
> org.gjt.mm.mysql.jdbc2.Connection@89cf1e[org.apache.ojb.broker
> .ta.PersistenceBrokerFactoryDefaultImpl] INFO: Already created
> persistence broker instances:
> 2[org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR:
> SQLException during the execution of the insert (for a
> com.quoteology.directory.Category): Invalid argument value:
> Duplicate entry '35' for key 1 Invalid argument value:
> Duplicate entry '35' for key
> 1[org.apache.ojb.odmg.ObjectEnvelopeTable] ERROR: Commit on
> object level failed for tx
> org.apache.ojb.odmg.TransactionImpl@342ba4 Invalid argument
> value: Duplicate entry '35' for key
> 1[org.apache.ojb.odmg.TransactionImpl] ERROR: Could not prepare
> for commit Invalid argument value: Duplicate entry '35' for key
> 1------------- ---------------- ---------------
> ------------- Standard Error -----------------
> java.sql.SQLException: Invalid argument value: Duplicate entry
> '35' for key 1        at
> org.gjt.mm.mysql.MysqlIO.sendCommand(Unknown Source)        at
> org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)       
> at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)       
> at org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
> Source)        at
> org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
> Source)        at
> org.apache.ojb.broker.accesslayer.JdbcAccess.executeInsert(Unk
> nown Source)        at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unk
> nown Source)        at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unk
> nown Source)        at
> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unk
> nown Source)        at
> org.apache.ojb.odmg.states.StateNewDirty.commit(Unknown Source)
>        at
>        org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown
>        Source) at
>        org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(U
>        nknown Source) at
>        org.apache.ojb.odmg.TransactionImpl.prepareForCommit(Un
>        known Source) at
>        org.apache.ojb.odmg.TransactionImpl.commit(Unknown
>        Source) at
>        com.quoteology.directory.ODMGTreeTest.testTree(ODMGTree
>        Test.java:94) at
>        sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>        Method) at
>        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMetho
>        dAccessorImpl.java:39) at
>        sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegat
>        ingMethodAccessorImpl.java:25) at
>        java.lang.reflect.Method.invoke(Method.java:324) at
>        junit.framework.TestCase.runTest(TestCase.java:154) at
>        junit.framework.TestCase.runBare(TestCase.java:127) at
>        junit.framework.TestResult$1.protect(TestResult.java:10
>        6) at
>        junit.framework.TestResult.runProtected(TestResult.java
>        :124) at
>        junit.framework.TestResult.run(TestResult.java:109) at
>        junit.framework.TestCase.run(TestCase.java:118) at
>        junit.framework.TestSuite.runTest(TestSuite.java:208) at
>        junit.framework.TestSuite.run(TestSuite.java:203) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.run(JUnitTestRunner.java:325) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.main(JUnitTestRunner.java:524)
>        java.sql.SQLException: Invalid argument value: Duplicate
>        entry '35' for key 1 at
>        org.gjt.mm.mysql.MysqlIO.sendCommand(Unknown Source) at
>        org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
>        at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)
>        at
>        org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
>        Source) at
>        org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
>        Source) at
>        org.apache.ojb.broker.accesslayer.JdbcAccess.executeIns
>        ert(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.odmg.states.StateNewDirty.commit(Unknown
>        Source) at
>        org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown
>        Source) at
>        org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(U
>        nknown Source) at
>        org.apache.ojb.odmg.TransactionImpl.prepareForCommit(Un
>        known Source) at
>        org.apache.ojb.odmg.TransactionImpl.commit(Unknown
>        Source) at
>        com.quoteology.directory.ODMGTreeTest.testTree(ODMGTree
>        Test.java:94) at
>        sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>        Method) at
>        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMetho
>        dAccessorImpl.java:39) at
>        sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegat
>        ingMethodAccessorImpl.java:25) at
>        java.lang.reflect.Method.invoke(Method.java:324) at
>        junit.framework.TestCase.runTest(TestCase.java:154) at
>        junit.framework.TestCase.runBare(TestCase.java:127) at
>        junit.framework.TestResult$1.protect(TestResult.java:10
>        6) at
>        junit.framework.TestResult.runProtected(TestResult.java
>        :124) at
>        junit.framework.TestResult.run(TestResult.java:109) at
>        junit.framework.TestCase.run(TestCase.java:118) at
>        junit.framework.TestSuite.runTest(TestSuite.java:208) at
>        junit.framework.TestSuite.run(TestSuite.java:203) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.run(JUnitTestRunner.java:325) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.main(JUnitTestRunner.java:524) rethrown as
>        org.apache.ojb.broker.PersistenceBrokerSQLException:
>        Invalid argument value: Duplicate entry '35' for key 1
>        at
>        org.apache.ojb.broker.accesslayer.JdbcAccess.executeIns
>        ert(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.st
>        ore(Unknown Source) at
>        org.apache.ojb.odmg.states.StateNewDirty.commit(Unknown
>        Source) at
>        org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown
>        Source) at
>        org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(U
>        nknown Source) at
>        org.apache.ojb.odmg.TransactionImpl.prepareForCommit(Un
>        known Source) at
>        org.apache.ojb.odmg.TransactionImpl.commit(Unknown
>        Source) at
>        com.quoteology.directory.ODMGTreeTest.testTree(ODMGTree
>        Test.java:94) at
>        sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>        Method) at
>        sun.reflect.NativeMethodAccessorImpl.invoke(NativeMetho
>        dAccessorImpl.java:39) at
>        sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegat
>        ingMethodAccessorImpl.java:25) at
>        java.lang.reflect.Method.invoke(Method.java:324) at
>        junit.framework.TestCase.runTest(TestCase.java:154) at
>        junit.framework.TestCase.runBare(TestCase.java:127) at
>        junit.framework.TestResult$1.protect(TestResult.java:10
>        6) at
>        junit.framework.TestResult.runProtected(TestResult.java
>        :124) at
>        junit.framework.TestResult.run(TestResult.java:109) at
>        junit.framework.TestCase.run(TestCase.java:118) at
>        junit.framework.TestSuite.runTest(TestSuite.java:208) at
>        junit.framework.TestSuite.run(TestSuite.java:203) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.run(JUnitTestRunner.java:325) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.main(JUnitTestRunner.java:524) Caused by:
>        java.sql.SQLException: Invalid argument value: Duplicate
>        entry '35' for key 1 at
>        org.gjt.mm.mysql.MysqlIO.sendCommand(Unknown Source) at
>        org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
>        at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)
>        at
>        org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
>        Source) at
>        org.gjt.mm.mysql.PreparedStatement.executeUpdate(Unknown
>        Source) ... 24 more
> org.odmg.TransactionAbortedException: Invalid argument value:
> Duplicate entry '35' for key 1        at
> org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown Source) 
>       at
>       org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(Un
>       known Source)  at
>       org.apache.ojb.odmg.TransactionImpl.prepareForCommit(Unk
>       nown Source)  at
>       org.apache.ojb.odmg.TransactionImpl.commit(Unknown
>       Source)  at
>       com.quoteology.directory.ODMGTreeTest.testTree(ODMGTreeT
>       est.java:94)  at
>       sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>       Method)  at
>       sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethod
>       AccessorImpl.java:39)  at
>       sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegati
>       ngMethodAccessorImpl.java:25)  at
>       java.lang.reflect.Method.invoke(Method.java:324)  at
>       junit.framework.TestCase.runTest(TestCase.java:154)  at
>       junit.framework.TestCase.runBare(TestCase.java:127)  at
>       junit.framework.TestResult$1.protect(TestResult.java:106)
>        at
>        junit.framework.TestResult.runProtected(TestResult.java
>        :124) at
>        junit.framework.TestResult.run(TestResult.java:109) at
>        junit.framework.TestCase.run(TestCase.java:118) at
>        junit.framework.TestSuite.runTest(TestSuite.java:208) at
>        junit.framework.TestSuite.run(TestSuite.java:203) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.run(JUnitTestRunner.java:325) at
>        org.apache.tools.ant.taskdefs.optional.junit.JUnitTestR
>        unner.main(JUnitTestRunner.java:524)-------------
>        ---------------- ---------------
> 
> NB>>>>>>>>>>>>> (testTree is not the testTree TestCase found in
> the OJB dist)
> 
> Testcase: testTree took 6.381 sec
>         Caused an ERROR
> Invalid argument value: Duplicate entry '35' for key 1
> org.odmg.TransactionAbortedException: Invalid argument value:
> Duplicate entry '35' for key 1        at
> org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown Source) 
>       at
>       org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(Un
>       known Source)  at
>       org.apache.ojb.odmg.TransactionImpl.prepareForCommit(Unk
>       nown Source)  at
>       org.apache.ojb.odmg.TransactionImpl.commit(Unknown
>       Source)  at
>       com.quoteology.directory.ODMGTreeTest.testTree(ODMGTreeT
>       est.java:94)  at
>       sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>       Method)  at
>       sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethod
>       AccessorImpl.java:39)  at
>       sun.reflect.DelegatingMethodAccessorImpl.invoke(Delegati
>       ngMethodAccessorImpl.java:25)
> 
> Testcase: testTree
> 
> --
> To unsubscribe, e-mail:  
> <mailto:[EMAIL PROTECTED]> For additional
> commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 

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

Reply via email to