Hi,

I have spent two days on the following problem: let a class A having an
object attribute bObj of class B. When I make an object aObj of class A
persistent and modify it, but without mofifying the bObj attribute, then
OJB tries to insert bObj into the database. As bObj already exists, JDO
fails.

Any idea on this ?

Below a full explanation of my problem.

Regards,

AB




I have a CTicket class with several attributes, including an object attribute of CDepartment type.

First, I create and make persistent a CTicket instance. It's ok, I have
no problem.
The attribute of type CDepartment is already persistant (and previously
stored in the DB).

Next, I make changes on this CTicket instance (but I don't modify the
attribute of CDepartment type). When I commit, the CTicket is dirty
(normal!) and the PersistenceBroker makes the update.
The CTicket is normally updated in the DB.
But after this update, the OjbStoreManager tries to flush the attribute
of type CDepartment. And, of course, the insert procedure failed because
this objet is already existing.

To correct this problem, I tried to add the "auto-update=none" tag for
this attribute in my repository file.


Here is the corresponding log:
[JDO] DEBUG: OjbStoreManager.flush:
org.esupportail.portal.channels.CHelpdesk.CTicket{214}, P_DIRTY
[JDO] DEBUG: OjbStoreManager.update
[org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG:
getObjectByIdentity org.esupportail.portal.channels.CHelpdesk.CTicket{214}
[org.apache.ojb.broker.accesslayer.StatementManager] DEBUG:
closeResources was called
[org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG:
getObjectByIdentity
org.esupportail.portal.channels.CHelpdesk.CUser{24007583}
[org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG:
getObjectByIdentity
org.esupportail.portal.channels.CHelpdesk.CUser{24007583}
[org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG:
getObjectByIdentity org.esupportail.portal.channels.CHelpdesk.CDepartment{1}
[JDO] DEBUG: OjbStoreConnector.flush: connectionReadyForRelease=false
[org.apache.ojb.broker.core.PersistenceBrokerImpl] INFO: Cascade
store for this reference-descriptor (owner) was set to false.
[org.apache.ojb.broker.core.PersistenceBrokerImpl] INFO: Cascade
store for this reference-descriptor (manager) was set to false.
[org.apache.ojb.broker.core.PersistenceBrokerImpl] INFO: Cascade
store for this reference-descriptor (department) was set to false.
[org.apache.ojb.broker.core.PersistenceBrokerImpl] INFO: Cascade
store for this reference-descriptor (connectionTicket) was set to false.
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG:
executeUpdate :
<ticket>
<id>214</id>
[...]
</ticket>
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG:
executeUpdate: [EMAIL PROTECTED]: UPDATE ticket
SET
owner_id='24007583',manager_id='24007583',department_id=1,origin=1,status=1,priority=-1,scope=1,label='2eme


ticket',computer='i259p45',creation_date='2004-06-21
08:55:44',last_action_date='2004-06-22 09:00:34',ascii_history='Label:
2eme ticket\nComputer: m\'en fous\n\nC\'est mon 2eme
ti.\n\n\ndgggggggggggggg\n\n\n',connection_ticket_id=null WHERE id = 214
     [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG:
closeResources was called
     [JDO] DEBUG: OjbStoreManager.flush:
org.esupportail.portal.channels.CHelpdesk.CDepartment{1}, P_NEW
     [JDO] DEBUG: OjbStoreManager.insert
     [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG:
executeInsert :
     <department>
      [...]
     </department>
     [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG:
executeInsert: [EMAIL PROTECTED]: INSERT INTO
department (id,label,xlabel,custom_classname,url,auto_expire,visible)
VALUES (1,'IFSIC','Institut de Formation Supérieur en Informatique et
Communication.','none','http://www.ifsic.univ-rennes1.fr',5,'1')
     [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG:
closeResources was called
     [JDO] DEBUG: OjbStoreConnector.rollback
     [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] INFO:
Rollback was called, do rollback on current connection
[EMAIL PROTECTED]
     [org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG: PB.close
was called: [EMAIL PROTECTED]
     org.apache.ojb.jdori.sql.OjbStoreFatalInternalException:
org.apache.ojb.jdori.sql.OjbStoreManager.insert
     NestedThrowables:
     org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure
while insert object data for class
org.esupportail.portal.channels.CHelpdesk.CDepartment, PK of the given
object is [ id=1], object was
     <department>
      [...]
     </department>, exception message is [Invalid argument value,
message from server: "Duplicata du champ '1' pour la clef 1"]
     at
org.apache.ojb.jdori.sql.OjbStoreManager.insert(OjbStoreManager.java:101)
     at com.sun.jdori.common.state.PersistentNew.flush(Unknown Source)
     at com.sun.jdori.common.state.StateManagerImpl.flush(Unknown Source)
     at
org.apache.ojb.jdori.sql.OjbStoreManager.flush(OjbStoreManager.java:304)
     at com.sun.jdori.common.CacheManagerImpl.flushInstances(Unknown
Source)
     at
com.sun.jdori.common.PersistenceManagerImpl.flushInstances(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.flushInstances(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.prepareFlush(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.commit(Unknown Source)
     at
org.esupportail.portal.channels.CHelpdesk.CTicket.addNewAction(CTicket.java:570)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionTakeTicket(CHelpdeskChannel.java:1009)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionControlPanel(CHelpdeskChannel.java:493)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionAuthenticated(CHelpdeskChannel.java:374)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transition(CHelpdeskChannel.java:321)
     at
org.esupportail.portal.channels.CJDOChannel.setRuntimeData(CJDOChannel.java:404)
     at
org.jasig.portal.ChannelRenderer$Worker.run(ChannelRenderer.java:412)
     at org.jasig.portal.utils.threading.Worker.run(Worker.java:88)
     Caused by: org.apache.ojb.broker.PersistenceBrokerSQLException:
SQL failure while insert object data for class
org.esupportail.portal.channels.CHelpdesk.CDepartment, PK of the given
object is [ id=1], object was
     <department>
      [...]
     </department>, exception message is [Invalid argument value,
message from server: "Duplicata du champ '1' pour la clef 1"]
     at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:242)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1620)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1537)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1493)
     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:180)
     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:180)
     at
org.apache.ojb.jdori.sql.OjbStoreManager.insert(OjbStoreManager.java:97)
     ... 16 more
     Caused by: java.sql.SQLException: Invalid argument value,  message
from server: "Duplicata du champ '1' pour la clef 1"
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
     at com.mysql.jdbc.Connection.execSQL(Connection.java:2051)
     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1680)
     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1527)
     at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:197)
     ... 22 more
     NestedThrowablesStackTrace:
     org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure
while insert object data for class
org.esupportail.portal.channels.CHelpdesk.CDepartment, PK of the given
object is [ id=1], object was
     <department>
      [...]
     </department>, exception message is [Invalid argument value,
message from server: "Duplicata du champ '1' pour la clef 1"]
     at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:242)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1620)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1537)
     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1493)
     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:180)
     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:180)
     at
org.apache.ojb.jdori.sql.OjbStoreManager.insert(OjbStoreManager.java:97)
     at com.sun.jdori.common.state.PersistentNew.flush(Unknown Source)
     at com.sun.jdori.common.state.StateManagerImpl.flush(Unknown Source)
     at
org.apache.ojb.jdori.sql.OjbStoreManager.flush(OjbStoreManager.java:304)
     at com.sun.jdori.common.CacheManagerImpl.flushInstances(Unknown
Source)
     at
com.sun.jdori.common.PersistenceManagerImpl.flushInstances(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.flushInstances(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.prepareFlush(Unknown Source)
     at com.sun.jdori.common.TransactionImpl.commit(Unknown Source)
     at
org.esupportail.portal.channels.CHelpdesk.CTicket.addNewAction(CTicket.java:570)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionTakeTicket(CHelpdeskChannel.java:1009)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionControlPanel(CHelpdeskChannel.java:493)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transitionAuthenticated(CHelpdeskChannel.java:374)
     at
org.esupportail.portal.channels.CHelpdesk.CHelpdeskChannel.transition(CHelpdeskChannel.java:321)
     at
org.esupportail.portal.channels.CJDOChannel.setRuntimeData(CJDOChannel.java:404)
     at
org.jasig.portal.ChannelRenderer$Worker.run(ChannelRenderer.java:412)
     at org.jasig.portal.utils.threading.Worker.run(Worker.java:88)
     Caused by: java.sql.SQLException: Invalid argument value,  message
from server: "Duplicata du champ '1' pour la clef 1"
     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876)
     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
     at com.mysql.jdbc.Connection.execSQL(Connection.java:2051)
     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1680)
     at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1527)
     at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:197)
     ... 22 more



--
Alexandre BOISSEAU
Université de Rennes1



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



Reply via email to