actual class of the exception:
class org.apache.openjpa.persistence.RollbackException
<2|true|0.9.7-incubating-SNAPSHOT>
org.apache.openjpa.persistence.RollbackException: The transaction has been
rolled back.  See the nested exceptions for details on the errors that
occurred.
        at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:417)
        at test.Main.main(Main.java:82)
Caused by: <0|true|0.9.7-incubating-SNAPSHOT>
org.apache.openjpa.persistence.PersistenceException: The transaction has
been rolled back.  See the nested exceptions for details on the errors that
occurred.
        at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2091)
        at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1938)
        at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1836)
        at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1754)
        at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:76)
        at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1311)
        at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:863)
        at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:406)
        ... 1 more
Caused by: <0|false|0.9.7-incubating-SNAPSHOT>
org.apache.openjpa.persistence.PersistenceException: The statement was
aborted because it would have caused a duplicate key value in a unique or
primary key constraint or unique index identified by 'SQL070403054930170'
defined on 'BSC'. {prepstmnt 15774883 INSERT INTO BSC (objid, objname,
created, msc_name, objclass) VALUES (?, ?, ?, ?, ?) [params=(long) 1,
(String) objname1, (Timestamp) 2006-05-04 18:13:51.0, (String) objname0,
(String) bsc]} [code=-1, state=23505]
FailedObject: [EMAIL PROTECTED]
        at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:3764)
        at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:94)
        at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:103)
        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:68)
        at
org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager.flushPrimaryRow(OperationOrderUpdateManager.java:200)
        at
org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager.flush(OperationOrderUpdateManager.java:86)
        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:86)
        at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:69)
        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:511)
        at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:127)
        ... 8 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: The statement
was aborted because it would have caused a duplicate key value in a unique
or primary key constraint or unique index identified by 'SQL070403054930170'
defined on 'BSC'. {prepstmnt 15774883 INSERT INTO BSC (objid, objname,
created, msc_name, objclass) VALUES (?, ?, ?, ?, ?) [params=(long) 1,
(String) objname1, (Timestamp) 2006-05-04 18:13:51.0, (String) objname0,
(String) bsc]} [code=-1, state=23505]
        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:188)
        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$800(LoggingConnectionDecorator.java:53)
        at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:854)
        at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:266)
        at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1360)
        at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:92)
        ... 15 more
FailedObject:null
 



Patrick Linskey wrote:
> 
>> <2|true|0.9.7-incubating-SNAPSHOT>
> org.apache.openjpa.util.StoreException:
> 
> You definitely should not be getting that exception -- OpenJPA should
> only be throwing exception types that are in the
> org.apache.openjpa.persistence package and sub-packages.
> 
> Can you print out the actual class of the exception that is thrown
> (i.e., System.err.println(e.getClass()) just in case the exception is
> just doing a bad job of printing itself out?
> 
> Thanks,
> 
> -Patrick
> 
> -- 
> Patrick Linskey
> BEA Systems, Inc. 
> 
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it. 
> 
>> -----Original Message-----
>> From: wanyna [mailto:[EMAIL PROTECTED] 
>> Sent: Tuesday, April 03, 2007 8:26 PM
>> To: open-jpa-dev@incubator.apache.org
>> Subject: why not an EntityExistsException was thrown?
>> 
>> 
>> I was confused in result of my test cases.
>> My test is about JPA exceptions. I use derby in my tests.
>> The first case is simply persist an object, the PK of the 
>> object has existed
>> in database,
>> so exception arose.
>>                      entityManager = factory.createEntityManager();
>>                      entityManager.getTransaction().begin();
>>                      ...
>>                      entityManager.persist(anObject);        
>>                      entityManager.getTransaction().commit();
>> exception is:
>> <2|true|0.9.7-incubating-SNAPSHOT> 
>> org.apache.openjpa.util.StoreException:
>> The transaction has been rolled back.  See the nested 
>> exceptions for details
>> on the errors that occurred.
>>      at
>> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerI
>> mpl.java:2091)
>>      at 
>> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1938)
>>      at 
>> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1836)
>>      at
>> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerIm
>> pl.java:1754)
>>      at
>> org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalMana
>> gedRuntime.java:76)
>>      at 
>> org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1311)
>>      at
>> org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBr
>> oker.java:863)
>>      at
>> org.apache.openjpa.persistence.EntityManagerImpl.commit(Entity
>> ManagerImpl.java:406)
>>      at test.Main.main(Main.java:82)
>> Caused by: <2|false|0.9.7-incubating-SNAPSHOT>
>> org.apache.openjpa.util.StoreException: The statement was 
>> aborted because it
>> would have caused a duplicate key value in a unique or primary key
>> constraint or unique index identified by 'SQL070403054930170' 
>> defined on
>> 'BSC'. {prepstmnt 15774883 INSERT INTO BSC (objid, objname, created,
>> msc_name, objclass) VALUES (?, ?, ?, ?, ?) [params=(long) 1, (String)
>> objname1, (Timestamp) 2006-05-04 18:13:51.0, (String) 
>> objname0, (String)
>> bsc]} [code=-1, state=23505]
>> FailedObject: [EMAIL PROTECTED]
>>      at
>> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBD
>> ictionary.java:3764)
>>      at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptio
>> ns.java:94)
>>      at
>> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptio
>> ns.java:64)
>>      at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.fl
>> ushInternal(PreparedStatementManagerImpl.java:103)
>>      at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.fl
>> ush(PreparedStatementManagerImpl.java:68)
>>      at
>> org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager.flu
>> shPrimaryRow(OperationOrderUpdateManager.java:200)
>>      at
>> org.apache.openjpa.jdbc.kernel.OperationOrderUpdateManager.flu
>> sh(OperationOrderUpdateManager.java:86)
>>      at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(Abs
>> tractUpdateManager.java:86)
>>      at
>> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(Abs
>> tractUpdateManager.java:69)
>>      at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStor
>> eManager.java:511)
>>      at
>> org.apache.openjpa.kernel.DelegatingStoreManager.flush(Delegat
>> ingStoreManager.java:127)
>>      ... 8 more
>> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: 
>> The statement
>> was aborted because it would have caused a duplicate key 
>> value in a unique
>> or primary key constraint or unique index identified by 
>> 'SQL070403054930170'
>> defined on 'BSC'. {prepstmnt 15774883 INSERT INTO BSC (objid, objname,
>> created, msc_name, objclass) VALUES (?, ?, ?, ?, ?) [params=(long) 1,
>> (String) objname1, (Timestamp) 2006-05-04 18:13:51.0, 
>> (String) objname0,
>> (String) bsc]} [code=-1, state=23505]
>>      at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(Lo
>> ggingConnectionDecorator.java:188)
>>      at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$
> 800(LoggingConnectionDecorator.java:53)
>>      at
>> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$Logging
> Connection>
> $LoggingPreparedStatement.executeUpdate(LoggingConnectionDecor
>> ator.java:854)
>>      at
>> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.execut
>> eUpdate(DelegatingPreparedStatement.java:266)
>>      at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPrepared
> Statement.executeUpdate(JDBCStoreManager.java:1360)
>>      at
>> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.fl
>> ushInternal(PreparedStatementManagerImpl.java:92)
>>      ... 15 more
>> 
>> I wonder why not an EntityExistsException was thrown?
>> 
>> In the second case, I add a query before persist,  
>>                      entityManager = factory.createEntityManager();
>>                      /*
>>                       * query before persist, even bofore 
>> transaction effects samely.
>>                       * this query makes exception thrown in 
>> persist section difference.
>>                       * it seems that query what entity is 
>> not important,
>>                       * but must get result and result must 
>> has some record.
>>                       */
>>                      entityManager.createQuery(jpql).getResultList();
>> 
>>                      entityManager.getTransaction().begin();
>>                      ...
>>                      entityManager.persist(anObject);        
>>                      entityManager.getTransaction().commit();
>> exception:
>> <2|false|0.9.7-incubating-SNAPSHOT>
>> org.apache.openjpa.persistence.EntityExistsException: An 
>> object of type
>> "generate.Bsc" with oid "generate.Bsc-1:objname1" already 
>> exists in this
>> context; another cannot be persisted.
>> FailedObject: [EMAIL PROTECTED]
>>      at 
>> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2370)
>>      at 
>> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2206)
>>      at
>> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingB
>> roker.java:991)
>>      at
>> org.apache.openjpa.persistence.EntityManagerImpl.persist(Entit
>> yManagerImpl.java:526)
>>      at test.Main.main(Main.java:72)
>> FailedObject:[EMAIL PROTECTED]
>> 
>> An EntityExistsException was thrown this time, why? 
>> 
>> Exception is different, and when exception was thrown is also 
>> different.
>> first case exception was caught at commit,
>> second case, exception was caught at persist, why?
>> 
>> -- 
>> View this message in context: 
>> http://www.nabble.com/why-not-an-EntityExistsException-was-thr
> own--tf3523673.html#a9830350
>> Sent from the open-jpa-dev mailing list archive at Nabble.com.
>> 
>> 
> 
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this by
> email and then delete it.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/why-not-an-EntityExistsException-was-thrown--tf3523673.html#a9830521
Sent from the open-jpa-dev mailing list archive at Nabble.com.

Reply via email to