You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Armin Waibel <ar...@code-au-lait.de> on 2004/01/05 02:22:29 UTC

[BUG] Really strange error when insert an object (with m:n relation)

Hi all,

If I run ODMGRollbackTest standalone all tests pass without problems. 
When I run all junit tests I got two failures in this test case when 
checkpoint() method is called and OJB try to store new Project objects 
without any assigned references.

Really strange is the stack trace

Caused by: org.apache.ojb.broker.KeyConstraintViolatedException: SQL 
failure while insert object data for class org.apache.ojb.broker.Role, 
PK of the given object is [ person_id=-480059290 project_id=-480059288], 
object was 
org.apache.ojb.broker.Role@18baf36[roleName=<null>,personId=-480059290,person=Anton,projectId=-480059288,project=Project 
2 [Anton],tasks=[]], exception message is [Violation of unique index: 
SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
(PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]]

Report a key constraint violation in PERSON_PROJECT indirection table. 
The PK are negative!! sequence manager never generates negative PK 
values. The inserted Project objects don't had associated Person 
objects. And a Person object with name 'Anton' is never used.

What to hell is going on? ;-)

regards,
Armin

*************************
test case snip
*************************
odmgZoosWhilePB = getDBObjectCount(tx.getBroker(), ODMGZoo.class);
projectsWhilePB = getDBObjectCount(tx.getBroker(), Project.class);
//store more
storeObjects(tx, getNewODMGZoos(5));
storeObjects(tx, getNewProjects(2));
// checkpoint, should bring objects to DB but shouldn't commit
tx.checkpoint();


*************************
junit stack trace
*************************
Testcase: testResultsWhileTransactionWithCheckpoint took 0,541 sec
	Caused an ERROR
null
org.apache.ojb.odmg.TransactionAbortedExceptionOJB
	at 
org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:217)
	at 
org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(TransactionImpl.java:340)
	at org.apache.ojb.odmg.TransactionImpl.checkpoint(TransactionImpl.java:474)
	at 
org.apache.ojb.odmg.ODMGRollbackTest.testResultsWhileTransactionWithCheckpoint(ODMGRollbackTest.java:135)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Caused by: org.apache.ojb.broker.KeyConstraintViolatedException: SQL 
failure while insert object data for class org.apache.ojb.broker.Role, 
PK of the given object is [ person_id=-480059290 project_id=-480059288], 
object was 
org.apache.ojb.broker.Role@18baf36[roleName=<null>,personId=-480059290,person=Anton,projectId=-480059288,project=Project 
2 [Anton],tasks=[]], exception message is [Violation of unique index: 
SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
(PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]]
	at 
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:277)
	at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1378)
	at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1295)
	at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1255)
	at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:171)
	at 
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:171)
	at org.apache.ojb.odmg.states.StateNewDirty.commit(StateNewDirty.java:148)
	at 
org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(ObjectEnvelopeTable.java:241)
	at 
org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:195)
	... 19 more
Caused by: java.sql.SQLException: Violation of unique index: 
SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
(PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]
	at org.hsqldb.Trace.getError(Unknown Source)
	at org.hsqldb.jdbcResultSet.<init>(Unknown Source)
	at org.hsqldb.jdbcConnection.executeStandalone(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(JdbcAccessImpl.java:236)
	... 27 more



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


Re: [BUG] Really strange error when insert an object (with m:n relation)

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi all,

I do some more test loops running ODMGRollbackTest standalone. All 
standalone loops pass without any failures.
Seems that fragments of previous tests still in the internals of OJB.

Could this be a result of the prefetching mechanism?
How we can get negative PK values within OJB?

regards,
Armin

Armin Waibel wrote:

> Hi all,
> 
> If I run ODMGRollbackTest standalone all tests pass without problems. 
> When I run all junit tests I got two failures in this test case when 
> checkpoint() method is called and OJB try to store new Project objects 
> without any assigned references.
> 
> Really strange is the stack trace
> 
> Caused by: org.apache.ojb.broker.KeyConstraintViolatedException: SQL 
> failure while insert object data for class org.apache.ojb.broker.Role, 
> PK of the given object is [ person_id=-480059290 project_id=-480059288], 
> object was 
> org.apache.ojb.broker.Role@18baf36[roleName=<null>,personId=-480059290,person=Anton,projectId=-480059288,project=Project 
> 2 [Anton],tasks=[]], exception message is [Violation of unique index: 
> SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
> (PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]]
> 
> Report a key constraint violation in PERSON_PROJECT indirection table. 
> The PK are negative!! sequence manager never generates negative PK 
> values. The inserted Project objects don't had associated Person 
> objects. And a Person object with name 'Anton' is never used.
> 
> What to hell is going on? ;-)
> 
> regards,
> Armin
> 
> *************************
> test case snip
> *************************
> odmgZoosWhilePB = getDBObjectCount(tx.getBroker(), ODMGZoo.class);
> projectsWhilePB = getDBObjectCount(tx.getBroker(), Project.class);
> //store more
> storeObjects(tx, getNewODMGZoos(5));
> storeObjects(tx, getNewProjects(2));
> // checkpoint, should bring objects to DB but shouldn't commit
> tx.checkpoint();
> 
> 
> *************************
> junit stack trace
> *************************
> Testcase: testResultsWhileTransactionWithCheckpoint took 0,541 sec
>     Caused an ERROR
> null
> org.apache.ojb.odmg.TransactionAbortedExceptionOJB
>     at 
> org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:217) 
> 
>     at 
> org.apache.ojb.odmg.TransactionImpl.doCommitOnObjects(TransactionImpl.java:340) 
> 
>     at 
> org.apache.ojb.odmg.TransactionImpl.checkpoint(TransactionImpl.java:474)
>     at 
> org.apache.ojb.odmg.ODMGRollbackTest.testResultsWhileTransactionWithCheckpoint(ODMGRollbackTest.java:135) 
> 
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> 
> Caused by: org.apache.ojb.broker.KeyConstraintViolatedException: SQL 
> failure while insert object data for class org.apache.ojb.broker.Role, 
> PK of the given object is [ person_id=-480059290 project_id=-480059288], 
> object was 
> org.apache.ojb.broker.Role@18baf36[roleName=<null>,personId=-480059290,person=Anton,projectId=-480059288,project=Project 
> 2 [Anton],tasks=[]], exception message is [Violation of unique index: 
> SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
> (PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]]
>     at 
> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:277) 
> 
>     at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1378) 
> 
>     at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1295) 
> 
>     at 
> org.apache.ojb.broker.core.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1255) 
> 
>     at 
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:171) 
> 
>     at 
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:171) 
> 
>     at 
> org.apache.ojb.odmg.states.StateNewDirty.commit(StateNewDirty.java:148)
>     at 
> org.apache.ojb.odmg.ObjectEnvelopeTable.commitAllEnvelopes(ObjectEnvelopeTable.java:241) 
> 
>     at 
> org.apache.ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:195) 
> 
>     ... 19 more
> Caused by: java.sql.SQLException: Violation of unique index: 
> SYS_PK_PERSON_PROJECT in statement [INSERT INTO PERSON_PROJECT 
> (PERSON_ID,PROJECT_ID,ROLENAME) VALUES (-480059290,-480059288,NULL) ]
>     at org.hsqldb.Trace.getError(Unknown Source)
>     at org.hsqldb.jdbcResultSet.<init>(Unknown Source)
>     at org.hsqldb.jdbcConnection.executeStandalone(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(JdbcAccessImpl.java:236) 
> 
>     ... 27 more
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 



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