I tried it with hsql and still receive an error. Still lost as to why a
violation of unique index would occur. The statement works fine if I execute
it outside of OJB. Is there any possibility the insert could occur twice in
the same transaction? Here's the output with the error:


[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the insert (for a xxx.bo.Notification): Violation of
unique index: SYS_PK_NOTIFICATION in statement [INSERT INTO notification
(notification_id,name,type) VALUES (16,'Test notification',NULL) ]
Violation of unique index: SYS_PK_NOTIFICATION in statement [INSERT INTO
notification (notification_id,name,type) VALUES (16,'Test
notification',NULL) ]
[org.apache.ojb.odmg.ObjectEnvelopeTable] ERROR: Commit on object level
failed for tx [EMAIL PROTECTED]
Violation of unique index: SYS_PK_NOTIFICATION in statement [INSERT INTO
notification (notification_id,name,type) VALUES (16,'Test
notification',NULL) ]
[org.apache.ojb.odmg.TransactionImpl] ERROR: Could not prepare for commit:
null
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO: Rollback was
called, do rollback on current connection [EMAIL PROTECTED]
------------- ---------------- ---------------
------------- Standard Error -----------------
java.sql.SQLException: Violation of unique index: SYS_PK_NOTIFICATION in
statement [INSERT INTO notification (notification_id,name,type) VALUES
(16,'Test notification',NULL) ]
        at org.hsqldb.Trace.getError(Unknown Source)
        at org.hsqldb.Result.<init>(Unknown Source)
        at org.hsqldb.jdbcConnection.executeHSQL(Unknown Source)
        at org.hsqldb.jdbcConnection.execute(Unknown Source)
        at org.hsqldb.jdbcStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbcStatement.executeUpdate(Unknown Source)
        at org.hsqldb.jdbcPreparedStatement.executeUpdate(Unknown Source)
        at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
Source)
        at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown
Source)
        at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown Source)
        at org.apache.ojb.odmg.states.StateNewDirty.commit(Unknown Source)
        at
org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(Unknown Source)
        at org.apache.ojb.odmg.ObjectEnvelopeTable.commit(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(Unknown
Source)
        at org.apache.ojb.odmg.TransactionImpl.prepare(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.commit(Unknown Source)

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 11, 2003 9:09 AM
To: OJB Users List
Subject: Re: Non-decomposed m:n mappings with ODMG


Hi Eric,

try to set up your test scenario using hsql to
see if this also fail. Should be easy to do
(use SequenceManagerInMemoryImpl - does
not need a database table).

regards,
Armin

----- Original Message -----
From: "Eric Northam" <[EMAIL PROTECTED]>
To: "'OJB Users List'" <[EMAIL PROTECTED]>
Sent: Wednesday, June 11, 2003 2:56 PM
Subject: RE: Non-decomposed m:n mappings with ODMG


> Still no luck with a clean database. There are three tables involved
in the
> mapping and there are no special constraints unless you consider the
primary
> keys which are listed as follows:
>
> lead table
> lead_id
>
> notification table
> notification_id
>
> notification_lead table
> lead_id
> notification_id
>
>
>
> -----Original Message-----
> From: Mauricio CASTRO [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 10, 2003 4:53 PM
> To: OJB Users List
> Subject: Re: Non-decomposed m:n mappings with ODMG
>
>
> May be you have DB constraints set like a PK. May be you have a unique 
> restriction in the lead table and you already inserted a record with
fn=eric
> and ln=Northam. Try to change the data and run it again or delete all
the
> tables.
>
>
> "Until they become conscious they will never rebel, and until after
they
> have rebelled they cannot become conscious" --Orwell 1984
> ----- Original Message -----
> From: "Eric Northam" <[EMAIL PROTECTED]>
> To: "'OJB Users List'" <[EMAIL PROTECTED]>
> Sent: Tuesday, June 10, 2003 3:41 PM
> Subject: RE: Non-decomposed m:n mappings with ODMG
>
>
> > Sure thing,
> >
> > The following causes a BatchUpdateException:
> >
> > Invalid argument value,  message from server: "Duplicate entry '41' 
> > for
> key
> > 1"
> > java.sql.BatchUpdateException: Invalid argument value,  message from
> server:
> > "Duplicate entry '41' for key 1
> >
> >     at
> >
com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:136
7)
> >     at
> >
>
org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.doEx
ecut
> > e(Unknown Source)
> >     at
> >
>
org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler.invo
ke(U
> > nknown Source)
> >     at $Proxy0.doExecute(Unknown Source)
> >     at
> org.apache.ojb.broker.util.batch.BatchConnection.executeBatch(Unknown
> > Source)
> >
> > ....
> >
> > --- Store code ----
> >
> >         Implementation odmg = OJB.getInstance();
> >         Database db = odmg.newDatabase();
> >
> >         Lead leadBO = new Lead();
> >         leadBO.setFirstName("Eric");
> >         leadBO.setLastName("Northam");
> >         leadBO.setEmail("[EMAIL PROTECTED]");
> >
> >         Notification notification = new Notification();
> >         notification.setName("Test notification");
> >
> >         ArrayList notifications = new ArrayList();
> >         notifications.add(notification);
> >         leadBO.setNotifications(notifications);
> >
> >         db.open(null, Database.OPEN_READ_WRITE);
> >
> >         Transaction tx = odmg.newTransaction();
> >
> >         tx.begin();
> >         tx.lock(leadBO, Transaction.WRITE);
> >         tx.commit();
> >
> > ---
> >
> > --- repository_user.xml ---
> >
> > <class-descriptor class="xxx.bo.Lead" table="lead">
<field-descriptor
> > name="id" column="lead_id" jdbc-type="INTEGER" primarykey="true" 
> > autoincrement="true"/> <field-descriptor name="firstName" 
> > column="first_name" jdbc-type="VARCHAR"/> <field-descriptor 
> > name="lastName" column="last_name" jdbc-type="VARCHAR"/>
> > <field-descriptor name="email" column="email"
> > jdbc-type="VARCHAR"/>
> > <collection-descriptor name="notifications"
> > element-class-ref="xxx.bo.Notification" auto-retrieve="true"
> > auto-update="true" indirection-table="notification_lead">
> > <fk-pointing-to-this-class column="lead_id"/>
> > <fk-pointing-to-element-class
> > column="notification_id"/>
> > </collection-descriptor>
> > </class-descriptor>
> >
> > <class-descriptor class="xxx.bo.Notification" table="notification"> 
> > <field-descriptor name="id" column="notification_id" 
> > jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> 
> > <field-descriptor name="name" column="name" jdbc-type="VARCHAR"/> 
> > <field-descriptor name="type" column="type" jdbc-type="VARCHAR"/>
> > <collection-descriptor name="leads"
> > element-class-ref="xxx.bo.Lead" auto-retrieve="true"
auto-update="true"
> > indirection-table="notification_lead" > <fk-pointing-to-this-class
> > column="notification_id"/>
> > <fk-pointing-to-element-class column="lead_id"/>
> > </collection-descriptor>
> > </class-descriptor>
> >
> > -------
> >
> >
> > TIA,
> >
> > Eric
> >
> > -----Original Message-----
> > From: Mauricio CASTRO [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, June 10, 2003 4:12 PM
> > To: OJB Users List
> > Subject: Re: Non-decomposed m:n mappings with ODMG
> >
> >
> > Eric,
> >
> > No, I use Postgesql. Try to post your repository_user.xml, and the 
> > source code that is supposed to do the work.
> >
> >
> > Mauricio Castro.
> >
> > "Until they become conscious they will never rebel, and until after 
> > they have rebelled they cannot become conscious" --Orwell 1984
> > ----- Original Message -----
> > From: "Eric Northam" <[EMAIL PROTECTED]>
> > To: "'OJB Users List'" <[EMAIL PROTECTED]>
> > Sent: Tuesday, June 10, 2003 3:12 PM
> > Subject: RE: Non-decomposed m:n mappings with ODMG
> >
> >
> > > You wouldn't happen to be using MySQL?
> > >
> > > -----Original Message-----
> > > From: Mauricio CASTRO [mailto:[EMAIL PROTECTED]
> > > Sent: Tuesday, June 10, 2003 4:06 PM
> > > To: OJB Users List
> > > Subject: Re: Non-decomposed m:n mappings with ODMG
> > >
> > >
> > >
> > > I succesfuly use an m:n mapping and ODMG.
> > >
> > > "Until they become conscious they will never rebel, and until
after
> > > they have rebelled they cannot become conscious" --Orwell 1984
> > > ----- Original Message -----
> > > From: "Eric Northam" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Tuesday, June 10, 2003 3:07 PM
> > > Subject: Non-decomposed m:n mappings with ODMG
> > >
> > >
> > > > Has anyone been able to store an object with an m:n mapping
using
> > > > the ODMG api? It works fine with the persistence broker but 
> > > > doesn't work with ODMG
> > > as
> > > > far as I can tell. Unfortunately I have several objects with a 
> > > > many to
> > > many
> > > > relationship so I'm wondering whether I should drop using the
ODMG
> > > > api all together. Is there any consequence to using both ODMG
and
> > > > the persistence broker together as a workaround?
> > > >
> > > > Eric
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > DISCLAIMER: The information contained in this e-mail is, unless 
> > > > otherwise indicated, confidential and is intended solely for the 
> > > > use of the named addressee. Access, copying or re-use of the 
> > > > e-mail or any information contained therein by any other person
is
> > > > not authorized. If you are not
> > > the
> > > > intended recipient please notify us immediately by returning the 
> > > > e-mail to the originator.
> > > >
> > >
> >
> --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > >
> > >
> > >
> > > DISCLAIMER: The information contained in this e-mail is, unless 
> > > otherwise indicated, confidential and is intended solely for the
use
> > > of the named addressee. Access, copying or re-use of the e-mail or 
> > > any information contained therein by any other person is not 
> > > authorized. If you are not
> > the
> > > intended recipient please notify us immediately by returning the 
> > > e-mail to the originator.
> > >
> >
>
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> > DISCLAIMER: The information contained in this e-mail is, unless 
> > otherwise indicated, confidential and is intended solely for the use 
> > of the named addressee. Access, copying or re-use of the e-mail or
any
> > information contained therein by any other person is not authorized. 
> > If you are not
> the
> > intended recipient please notify us immediately by returning the 
> > e-mail to the originator.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
> DISCLAIMER: The information contained in this e-mail is, unless
otherwise
> indicated, confidential and is intended solely for the use of the
named
> addressee. Access, copying or re-use of the e-mail or any information 
> contained therein by any other person is not authorized. If you are
not the
> intended recipient please notify us immediately by returning the
e-mail to
> the originator.
>



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





DISCLAIMER: The information contained in this e-mail is, unless otherwise
indicated, confidential and is intended solely for the use of the named
addressee. Access, copying or re-use of the e-mail or any information
contained therein by any other person is not authorized. If you are not the
intended recipient please notify us immediately by returning the e-mail to
the originator.

Reply via email to