You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Pinaki Poddar (JIRA)" <ji...@apache.org> on 2013/05/06 16:38:16 UTC

[jira] [Updated] (OPENJPA-2373) MapsId in a Child entity to a Parent entity using auto-assigned identity fails with duplicte INSERT SQL

     [ https://issues.apache.org/jira/browse/OPENJPA-2373?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pinaki Poddar updated OPENJPA-2373:
-----------------------------------

    Attachment: graycol.gif


Albert,
  I will take a look.
  1. May take a little while.
  2. Is there a Orace instance that can be accessed outside the BSO
firewall?


Regards --

Pinaki








From:	"Albert Lee (JIRA)" <ji...@apache.org>
To:	Pinaki Poddar/Dallas/IBM@IBMUS
Date:	05/05/2013 10:24 AM
Subject:	[jira] [Commented] (OPENJPA-2373) MapsId in a Child entity to a
            Parent entity using auto-assigned identity fails with duplicte
            INSERT SQL




    [
https://issues.apache.org/jira/browse/OPENJPA-2373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13649374#comment-13649374
 ]

Albert Lee commented on OPENJPA-2373:
-------------------------------------

TestMapsIdWithAutoGeneratedKey was introduced in r1469652. This passes
against Derby but failed with Oracle withe the following error. Based on
the symptom, this may be related to the error introduced by OPENJPA-2328
and OPENJPA-2378

     73   <testcase time="1.374"
classname="org.apache.openjpa.persistence.inheritance.jointable.onetomany.TestMapsIdWithAutoGeneratedKey"
 name="testPersistShirtWithPart">
     74     <error message="The transaction has been rolled back.  See the
nested exceptions for details on the errors that occurred."
type="&lt;openjpa-2.3.0-SNAPSHOT-r422266">&lt;openjpa-2.3.0-SN
APSHOT-r422266:1469652 fatal store error&gt;
org.apache.openjpa.persistence.RollbackException: The transaction has been
rolled back.  See the nested exceptions for details on the errors tha
t occurred.
     75 FailedObject:
org.apache.openjpa.persistence.common.apps.Shirt@426b51d8
     76   at org.apache.openjpa.persistence.EntityManagerImpl.commit
(EntityManagerImpl.java:594)
     77   at
org.apache.openjpa.persistence.inheritance.jointable.onetomany.TestMapsIdWithAutoGeneratedKey.testPersistShirtWithPart
(TestMapsIdWithAutoGeneratedKey.java:94)
     78   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

......

    108 Caused by: &lt;openjpa-2.3.0-SNAPSHOT-r422266:1469652 fatal general
error&gt; org.apache.openjpa.persistence.PersistenceException: The
transaction has been rolled back.  See the nested exce        ptions for
details on the errors that occurred.
    109 FailedObject:
org.apache.openjpa.persistence.common.apps.Shirt@426b51d8
    110   at org.apache.openjpa.kernel.BrokerImpl.newFlushException
(BrokerImpl.java:2366)
    111   at org.apache.openjpa.kernel.BrokerImpl.flush
(BrokerImpl.java:2203)
    112   at org.apache.openjpa.kernel.BrokerImpl.flushSafe
(BrokerImpl.java:2101)
    113   at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion
(BrokerImpl.java:2019)
    114   at org.apache.openjpa.kernel.LocalManagedRuntime.commit
(LocalManagedRuntime.java:81)
    115   at org.apache.openjpa.kernel.BrokerImpl.commit
(BrokerImpl.java:1524)
    116   at org.apache.openjpa.kernel.DelegatingBroker.commit
(DelegatingBroker.java:933)
    117   at org.apache.openjpa.persistence.EntityManagerImpl.commit
(EntityManagerImpl.java:570)
    118   ... 31 more
    119 Caused by: &lt;openjpa-2.3.0-SNAPSHOT-r422266:1469652 fatal store
error&gt; org.apache.openjpa.persistence.EntityExistsException: ORA-01400:
cannot insert NULL into
(&quot;SCOTT&quot;.&quot        ;MPTZZT&quot;.&quot;ID_TXE&quot;)
    120  {prepstmnt 259984788 INSERT INTO MPTZZT (NA_TXE) VALUES (?)}
[code=1400, state=23000]
    121 FailedObject:
org.apache.openjpa.persistence.common.apps.Shirt@426b51d8
    122   at org.apache.openjpa.jdbc.sql.DBDictionary.narrow
(DBDictionary.java:4942)
    123   at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException
(DBDictionary.java:4917)
    124   at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore
(SQLExceptions.java:136)
    125   at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore
(SQLExceptions.java:78)
    126   at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate
(PreparedStatementManagerImpl.java:144)
    127   at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate
(BatchingPreparedStatementManagerImpl.java:79)
    128   at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal
(PreparedStatementManagerImpl.java:100)
    129   at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush
(PreparedStatementManagerImpl.java:88)
    130   at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush
(ConstraintUpdateManager.java:357)
    131   at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flushGraph
(ConstraintUpdateManager.java:349)
    132   at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush
(ConstraintUpdateManager.java:97)
    133   at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush
(BatchingConstraintUpdateManager.java:59)
    134   at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush
(AbstractUpdateManager.java:105)
    135   at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush
(AbstractUpdateManager.java:78)
    136   at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush
(JDBCStoreManager.java:732)
    137   at org.apache.openjpa.kernel.DelegatingStoreManager.flush
(DelegatingStoreManager.java:131)
    138   ... 38 more
    139 Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
ORA-01400: cannot insert NULL into
(&quot;SCOTT&quot;.&quot;MPTZZT&quot;.&quot;ID_TXE&quot;)
    140  {prepstmnt 259984788 INSERT INTO MPTZZT (NA_TXE) VALUES (?)}
[code=1400, state=23000]
    141   at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap
(LoggingConnectionDecorator.java:219)
    142   at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap
(LoggingConnectionDecorator.java:195)
    143   at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access
$1000(LoggingConnectionDecorator.java:59)
    144   at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
$LoggingConnection$LoggingPreparedStatement.executeUpdate
(LoggingConnectionDecorator.java:1134)
    145   at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate
(DelegatingPreparedStatement.java:275)
    146   at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate
(DelegatingPreparedStatement.java:275)
    147   at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate
(PreparedStatementManagerImpl.java:268)
    148   at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate
(PreparedStatementManagerImpl.java:119)
    149   ... 49 more


fails with duplicte INSERT SQL
--------------------------------------------------------------------------------------------------------

(parent). P uses auto-generated identity.
database to assign an identity. When C is flushed, it wrongly creates a row
for P again while handling the field p that points to parent.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA
administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


                
> MapsId in a Child entity to a Parent entity using auto-assigned identity fails with duplicte INSERT SQL 
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-2373
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2373
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 2.0.1, 2.1.1, 2.2.1
>            Reporter: Pinaki Poddar
>            Assignee: Pinaki Poddar
>             Fix For: 2.3.0
>
>         Attachments: graycol.gif
>
>
> A MapsId annotation in entity C (child) annotates a field p of type P (parent). P uses auto-generated identity. 
> P-C is a bidirectional parent-child relationship.
>  
> During flush sequence, A row is created for P and flushed for the database to assign an identity. When C is flushed, it wrongly creates a row for P again while handling the field p that points to parent.
> Of course, the commit breaks with a DuplicateKeyException on P's table. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira