You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Gustavo E Faerman <gf...@fys.com.ar> on 2004/10/09 22:00:10 UTC

Re: 3rd Post Added stack trace: Problems with OTM when tring to persist objects with duplicate keys.]]

Thanks Armin for your answer.

OTM-api is really cool. What would you recommend in order to have Object
TX in place? (PB api tx are database tx aren´t they?. We do not like the
JDO enhancement stuff that much, and ODMG seems to be fading.

regards,
Gustavo.

On Vie, 8 de Octubre de 2004, 5:04 pm, Armin Waibel dijo:
> Hi Gustavo,
>
> sorry for the late reply.
>
> It's sad, but currently no one is working on the OTM layer. We
> concentrate on OJB 1.0.x (branch OJB_1_0_RELEASE) and on OJB 1.1 (CVS
> head, basically work on PB-api).
>
>  > org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
>  > Source)	at
> org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl.executeInsert(Unk
>
> It seems that you use latest CVS head. This code is a alpha version of
> OJB 1.1 and do not not pass the test-suite (some tests cases fail).
> OTM-api is currently not officially supported, the intension was to use
> OTM as a layer for JDO 2.
>
> regards,
> Armin
>
>
>
> Gustavo E Faerman wrote:
>
>> I' m so sorry for the typos in your name Jakob in our previous post !
>>
>> Have not find an answer to our problem. It might be a silly question for
>> java/OJB gurus out there, but we're still in the dark here with dups
>> keys
>> and OTM.
>>
>> Any enlightning will be apreciated!
>> Regards,
>> Gustavo.
>> ---------------------------- Mensaje original
>> ----------------------------
>> Asunto: 2nd Post Added stack trace: Problems with OTM when tring to
>>    persist objects with duplicate      keys.] De:     "Gustavo E
>> Faerman"
>> <gf...@fys.com.ar>
>> Fecha:  Mie, 6 de Octubre de 2004, 10:27 am
>> Para:   ojb-user@db.apache.org
>> --------------------------------------------------------------------------
>>
>> Jacob, Thomas et all.
>>
>> Need your help to catch the
>> org.apache.ojb.broker.KeyConstraintViolatedException (using OTM API)
>> when
>> trying to insert an object with a duplicate key (index not accepting dup
>> keys). The first run is not throwing the LockingException.
>>
>> We are executing the following code (OTM API):
>> where aGrabar is a reference to a given object that implementes the
>> FYSentity interface (a common interface we implement in our persistent
>> objects).
>>
>>  private static int inserto(FYSentity aGrabar){
>>     setConn();  //setups _kit (TestKit) and _conn (OTMConnection)
>>     try {
>>       tx = _kit.getTransaction(_conn); // 1. abro transaccion
>>       tx.begin();
>>       _conn.makePersistent(aGrabar);
>>       tx.commit();
>>       _conn.invalidateAll();
>>     }
>>    catch (LockingException e) {
>>       if (tx.isInProgress()) {
>>         tx.rollback();
>>       }
>>       //throw e;
>>       return 8; //no puede hacer el lock
>>     }
>>    catch (Exception e){  //added to try to intercept
>>       tx.rollback();     //uncaught exceptions
>>       e.getStackTrace();
>>       return 9;
>>     }
>>     PersistenceBrokerFactory.releaseAllInstances();
>>     _conn.close();
>>     _conn = null;
>>     return 0;
>>   }
>>
>> .
>>
>>
>>
>> The following stack trace seems to be thrown by core OJB code, not our
>> catch statements:
>> org.apache.ojb.broker.KeyConstraintViolatedException: SQL failure while
>> insert object data for class ar.com.fys.seguridad.UsuarioImpl, PK of the
>> given object is [ oID=8E8D673B-76A6-DAC6-B5AF-72F71E5CBC15], object was
>> ar.com.fys.seguridad.Usuario: 8E8D673B-76A6-DAC6-B5AF-72F71E5CBC15,
>> exception message is [Duplicate key or integrity constraint violation
>> message from server: "Duplicate entry 'admin' for key 2"] at
>> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
>> Source)	at
>> org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl.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.broker.core.DelegatingPersistenceBroker.store(Unknown
>> Source)
>>
>> 	at
>> org.apache.ojb.otm.core.ConcreteEditingContext.checkpointInternal(Unknown
>> Source)
>>
>> 	at org.apache.ojb.otm.core.ConcreteEditingContext.commit(Unknown
>> Source)
>>
>> 	at org.apache.ojb.otm.core.Transaction.commit(Unknown Source)
>>
>> 	at
>> ar.com.fys.tagrer.servidor.controlador.ControladorBD.inserto(ControladorBD.java:161)
>>
>> 	at
>> ar.com.fys.tagrer.servidor.controlador.ControladorBD.grabar(ControladorBD.java:131)
>>
>> 	at
>> ar.com.fys.tagrer.initSistema.InitSistema.grabaClases(InitSistema.java:128)
>>
>> 	at
>> ar.com.fys.tagrer.initSistema.InitSistema.<init>(InitSistema.java:46)
>>
>> 	at ar.com.fys.tagrer.initSistema.InitSistema.main(InitSistema.java:133)
>>
>> Caused by: java.sql.SQLException: Duplicate key or integrity constraint
>> violation message from server: "Duplicate entry 'admin' for key 2"
>>
>> 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
>>
>> 	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
>>
>> 	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
>>
>> 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
>>
>> 	at
>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
>>
>> 	at
>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
>>
>>
>>
>>
>>
>> *********************************************************
>> Hi all,
>>
>> We cannot find a way to properly handle exceptions with duplicate keys
>> When trying to persist an object with a column indexed not accepting
>> duplicates usitn OTM.
>>
>> Weir behaviour if we try to run our code twice in a row:
>> Stack trace shows in the first run
>> org.apache.ojb.broker.KeyConstraintViolatedException.
>>
>> Second run will throw LockingException. We cannot catch this
>> KeyConstranintVialoatedException when using OTM no matter where we use
>> catch try statements.
>>
>> Any ideas out there?
>>
>> Thanks in advance,
>> Gustavo.
>>
>>
>>
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: 3rd Post Added stack trace: Problems with OTM when tring to persist objects with duplicate keys.]]

Posted by Armin Waibel <ar...@apache.org>.
Gustavo E Faerman wrote:
> Thanks Armin for your answer.
> 
> OTM-api is really cool. What would you recommend in order to have Object
> TX in place? (PB api tx are database tx aren´t they?. We do not like the
> JDO enhancement stuff that much, and ODMG seems to be fading.
>

Right you are. There is a manpower bottleneck so none is working on OTM 
and all top-level api rely on the PB-api, so we first concentrate on 1.1 
PB-api and OJB1.0.x. OTM needs refactoring (some really complex methods) 
and bug fixing. Brian started to roll out the object graph statement 
tracking
http://db.apache.org/commons/sandbox/grafolia/
but this stuff is alpha state.
All help is welcome ;-)

regards,
Armin

> regards,
> Gustavo.
> 
> On Vie, 8 de Octubre de 2004, 5:04 pm, Armin Waibel dijo:
> 
>>Hi Gustavo,
>>
>>sorry for the late reply.
>>
>>It's sad, but currently no one is working on the OTM layer. We
>>concentrate on OJB 1.0.x (branch OJB_1_0_RELEASE) and on OJB 1.1 (CVS
>>head, basically work on PB-api).
>>
>> > org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
>> > Source)	at
>>org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl.executeInsert(Unk
>>
>>It seems that you use latest CVS head. This code is a alpha version of
>>OJB 1.1 and do not not pass the test-suite (some tests cases fail).
>>OTM-api is currently not officially supported, the intension was to use
>>OTM as a layer for JDO 2.
>>
>>regards,
>>Armin
>>
>>
>>
>>Gustavo E Faerman wrote:
>>
>>
>>>I' m so sorry for the typos in your name Jakob in our previous post !
>>>
>>>Have not find an answer to our problem. It might be a silly question for
>>>java/OJB gurus out there, but we're still in the dark here with dups
>>>keys
>>>and OTM.
>>>
>>>Any enlightning will be apreciated!
>>>Regards,
>>>Gustavo.
>>>---------------------------- Mensaje original
>>>----------------------------
>>>Asunto: 2nd Post Added stack trace: Problems with OTM when tring to
>>>   persist objects with duplicate      keys.] De:     "Gustavo E
>>>Faerman"
>>><gf...@fys.com.ar>
>>>Fecha:  Mie, 6 de Octubre de 2004, 10:27 am
>>>Para:   ojb-user@db.apache.org
>>>--------------------------------------------------------------------------
>>>
>>>Jacob, Thomas et all.
>>>
>>>Need your help to catch the
>>>org.apache.ojb.broker.KeyConstraintViolatedException (using OTM API)
>>>when
>>>trying to insert an object with a duplicate key (index not accepting dup
>>>keys). The first run is not throwing the LockingException.
>>>
>>>We are executing the following code (OTM API):
>>>where aGrabar is a reference to a given object that implementes the
>>>FYSentity interface (a common interface we implement in our persistent
>>>objects).
>>>
>>> private static int inserto(FYSentity aGrabar){
>>>    setConn();  //setups _kit (TestKit) and _conn (OTMConnection)
>>>    try {
>>>      tx = _kit.getTransaction(_conn); // 1. abro transaccion
>>>      tx.begin();
>>>      _conn.makePersistent(aGrabar);
>>>      tx.commit();
>>>      _conn.invalidateAll();
>>>    }
>>>   catch (LockingException e) {
>>>      if (tx.isInProgress()) {
>>>        tx.rollback();
>>>      }
>>>      //throw e;
>>>      return 8; //no puede hacer el lock
>>>    }
>>>   catch (Exception e){  //added to try to intercept
>>>      tx.rollback();     //uncaught exceptions
>>>      e.getStackTrace();
>>>      return 9;
>>>    }
>>>    PersistenceBrokerFactory.releaseAllInstances();
>>>    _conn.close();
>>>    _conn = null;
>>>    return 0;
>>>  }
>>>
>>>.
>>>
>>>
>>>
>>>The following stack trace seems to be thrown by core OJB code, not our
>>>catch statements:
>>>org.apache.ojb.broker.KeyConstraintViolatedException: SQL failure while
>>>insert object data for class ar.com.fys.seguridad.UsuarioImpl, PK of the
>>>given object is [ oID=8E8D673B-76A6-DAC6-B5AF-72F71E5CBC15], object was
>>>ar.com.fys.seguridad.Usuario: 8E8D673B-76A6-DAC6-B5AF-72F71E5CBC15,
>>>exception message is [Duplicate key or integrity constraint violation
>>>message from server: "Duplicate entry 'admin' for key 2"] at
>>>org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
>>>Source)	at
>>>org.apache.ojb.broker.accesslayer.batch.BatchManagerImpl.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.broker.core.DelegatingPersistenceBroker.store(Unknown
>>>Source)
>>>
>>>	at
>>>org.apache.ojb.otm.core.ConcreteEditingContext.checkpointInternal(Unknown
>>>Source)
>>>
>>>	at org.apache.ojb.otm.core.ConcreteEditingContext.commit(Unknown
>>>Source)
>>>
>>>	at org.apache.ojb.otm.core.Transaction.commit(Unknown Source)
>>>
>>>	at
>>>ar.com.fys.tagrer.servidor.controlador.ControladorBD.inserto(ControladorBD.java:161)
>>>
>>>	at
>>>ar.com.fys.tagrer.servidor.controlador.ControladorBD.grabar(ControladorBD.java:131)
>>>
>>>	at
>>>ar.com.fys.tagrer.initSistema.InitSistema.grabaClases(InitSistema.java:128)
>>>
>>>	at
>>>ar.com.fys.tagrer.initSistema.InitSistema.<init>(InitSistema.java:46)
>>>
>>>	at ar.com.fys.tagrer.initSistema.InitSistema.main(InitSistema.java:133)
>>>
>>>Caused by: java.sql.SQLException: Duplicate key or integrity constraint
>>>violation message from server: "Duplicate entry 'admin' for key 2"
>>>
>>>	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
>>>
>>>	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
>>>
>>>	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
>>>
>>>	at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
>>>
>>>	at
>>>com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1772)
>>>
>>>	at
>>>com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1619)
>>>
>>>
>>>
>>>
>>>
>>>*********************************************************
>>>Hi all,
>>>
>>>We cannot find a way to properly handle exceptions with duplicate keys
>>>When trying to persist an object with a column indexed not accepting
>>>duplicates usitn OTM.
>>>
>>>Weir behaviour if we try to run our code twice in a row:
>>>Stack trace shows in the first run
>>>org.apache.ojb.broker.KeyConstraintViolatedException.
>>>
>>>Second run will throw LockingException. We cannot catch this
>>>KeyConstranintVialoatedException when using OTM no matter where we use
>>>catch try statements.
>>>
>>>Any ideas out there?
>>>
>>>Thanks in advance,
>>>Gustavo.
>>>
>>>
>>>
>>>--------------------------------------------------------------------- To
>>>unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>>
>>>
>>>
>>>--------------------------------------------------------------------- To
>>>unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org