I get this stack trace in the standard error output under Oracle, although the
test case doesn't actually fail for some reason:
1031686985564|20|4|statement||DELETE FROM PERSON_PROJECT WHERE (PROJECT_ID = 1)
1031686985574|10|4|statement||INSERT INTO PERSON_PROJECT (PROJECT_ID,PERSON_ID) VALUES
( 1,1 )
1031686985574|0|4|statement||INSERT INTO PERSON_PROJECT (PROJECT_ID,PERSON_ID) VALUES
( 1,2 )
1031686985574|0|4|statement||INSERT INTO PERSON_PROJECT (PROJECT_ID,PERSON_ID) VALUES
( 1,4 )
1031686985574|0|4|statement||INSERT INTO PERSON_PROJECT (PROJECT_ID,PERSON_ID) VALUES
( 1,4 )
java.sql.SQLException: ORA-00001: unique constraint (SCOTT.PERSON_PROJECT_PK) violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
....
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
1031686985594|10|4|statement||INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES
( 1,1 )
[org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: SQLException during the
execution of the Update SQL query (for a org.apache.ojb.broker.Person): ORA-00001:
unique constraint (SCOTT.PERSON_PROJECT_PK) violated
ORA-00001: unique constraint (SCOTT.PERSON_PROJECT_PK) violated
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
...
at
org.apache.ojb.broker.accesslayer.JdbcAccess.executeUpdateSQL(JdbcAccess.java:319)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeMtoNImplementor(PersistenceBrokerImpl.java:764)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeCollections(PersistenceBrokerImpl.java:710)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1548)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:564)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:520)
at org.apache.ojb.broker.MtoNMapping.testInsertion(MtoNMapping.java:219)
This is repeated for value (1,2) as well. If unique primary keys are not
enforced the M:N relationship will work well enough but there will be
unnecessary records in the joining table.
You can reproduce this using Hypersonic as follows:
1. build junit
2. build prepare-testdb
3. Edit target/test/OJB.script and change the PERSON_PROJECT line this
(adds UNIQUE constraint):
CREATE TABLE PERSON_PROJECT(PERSON_ID INTEGER,PROJECT_ID INTEGER,ROLENAME
VARCHAR(20),CONSTRAINT SYS_PK_PERSON_PROJECT PRIMARY
KEY(PERSON_ID,PROJECT_ID),CONSTRAINT SYS_UNIQUE_PERSON_RPOJECT
UNIQUE(PERSON_ID,PROJECT_ID))
4. build junit-no-compile-no-prepare
5. Check standard error output in target/test/tests-broker.txt
Sorry, I had a go at analyzing the cause but failed miserably. :-)
--
Best regards,
David
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>