Hi,
Before the refactoring, we had (database table view):
JAMES_MAILBOX <-- JAMES_MAILBOX_MEMBERSHIP --> JAMES_MAIL
The cascade delete between mailbox and mailbox_membership had been
explicitly desactivated to avoid deletion of mailbox when a mail was
deleted (if you add the cascade, any mail deletion will try to delete
the mailbox...).
The tests were running fine before, this means that the tests didn't try
to delete mailbox with existing linked mails. If the tests had tried to
do it, it would also have failed (as far as I understand).
Now, after refactoring, we have:
JAMES_MAILBOX <-- JAMES_MAIL
The cascade delete between mail and mailbox is still desactivated, which
is good, otherwise any mail delete will try to delete the mailbox. But
it seems that the tests try to delete with mail attached to them.
I had a quick look to the changes, and the only question I have is about
[1], but this should not impact the link between mailbox and mail.
I will also try on my side, running the integration tests and looking at
the generated database.
A possibility would be that the delete of mails does not work, so at a
time, when test want to delet mailbox, there are still mails.
Tks,
- Eric
[1] in AbstractJPAMessage, why changing the link to Property and Header?
@ElementJoinColumns({@ElementJoinColumn(name="MAILBOX_ID",
referencedColumnName="MAILBOX_ID"),
@ElementJoinColumn(name="MAIL_UID", referencedColumnName="MAIL_UID")})
On 28/04/2011 22:59, Felix Knecht wrote:
Hi Norman
Just an idea what could cause the problem
1. We moved from jdk 1.5 to 1.6.
2. We updated the openjpa
Maybe 1. or 2. have now cascading delete disabled by default or it's
more strict with the latest versions?
From
/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
<snip>
/** The value for the mailboxId field */
@Id
@ManyToOne(
cascade = {
CascadeType.PERSIST,
CascadeType.REFRESH,
CascadeType.MERGE},
fetch=FetchType.LAZY)
@Column(name = "MAILBOX_ID", nullable = true)
private JPAMailbox mailbox;
</snip>
This has no cascading delete, but all others cascading.
As already said, just an idea ...
Regards
Felix
On 04/28/2011 10:02 PM, Norman Maurer wrote:
Hi there,
anyone can help me to understand why I get this exception after the
latest refactoring:
1390 [main] INFO sessionLog - Delete failed
org.apache.james.mailbox.MailboxException: Delete of mailbox Mailbox (
mailboxId = 2 name = selected uidValidity = 1869794862 ) failed
at
org.apache.james.mailbox.jpa.mail.JPAMailboxMapper.delete(JPAMailboxMapper.java:108)
at
org.apache.james.mailbox.store.StoreMailboxManager$2.runVoid(StoreMailboxManager.java:304)
at
org.apache.james.mailbox.store.transaction.Mapper$VoidTransaction.run(Mapper.java:67)
at
org.apache.james.mailbox.store.transaction.Mapper$VoidTransaction.run(Mapper.java:64)
at
org.apache.james.mailbox.store.transaction.TransactionalMapper.execute(TransactionalMapper.java:38)
at
org.apache.james.mailbox.store.StoreMailboxManager.deleteMailbox(StoreMailboxManager.java:297)
at
org.apache.james.imap.processor.DeleteProcessor.doProcess(DeleteProcessor.java:59)
at
org.apache.james.imap.processor.DeleteProcessor.doProcess(DeleteProcessor.java:35)
at
org.apache.james.imap.processor.AbstractMailboxProcessor.doProcess(AbstractMailboxProcessor.java:89)
at
org.apache.james.imap.processor.AbstractMailboxProcessor.process(AbstractMailboxProcessor.java:78)
at
org.apache.james.imap.processor.AbstractMailboxProcessor.doProcess(AbstractMailboxProcessor.java:72)
at
org.apache.james.imap.processor.AbstractMailboxProcessor.doProcess(AbstractMailboxProcessor.java:55)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:55)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.processor.base.AbstractChainedProcessor.process(AbstractChainedProcessor.java:57)
at
org.apache.james.imap.main.AbstractImapRequestHandler.doProcessRequest(AbstractImapRequestHandler.java:55)
at
org.apache.james.imap.main.ImapRequestStreamHandler.handleRequest(ImapRequestStreamHandler.java:77)
at
org.apache.james.imap.tester.ImapHostSystem$Session.readLine(ImapHostSystem.java:123)
at
org.apache.james.imap.tester.base.ProtocolSession$ServerResponse.readLine(ProtocolSession.java:349)
at
org.apache.james.imap.tester.base.ProtocolSession$ServerResponse.checkResponse(ProtocolSession.java:313)
at
org.apache.james.imap.tester.base.ProtocolSession$ServerResponse.testProtocol(ProtocolSession.java:303)
at
org.apache.james.imap.tester.base.ProtocolSession.runSessions(ProtocolSession.java:92)
at
org.apache.james.imap.tester.base.AbstractProtocolTestFramework.runSessions(AbstractProtocolTestFramework.java:111)
at
org.apache.james.imap.tester.base.AbstractSimpleScriptedTestProtocol.scriptTest(AbstractSimpleScriptedTestProtocol.java:74)
at
org.apache.james.imap.tester.suite.SelectedState.testCheckUS(SelectedState.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
at
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by:<openjpa-2.1.0-r422266:1071316 fatal general error>
org.apache.openjpa.persistence.PersistenceException: Referential
integrity constraint violation: "CONSTRAINT_9:
PUBLIC.JAMES_MAIL_JAMES_MAIL_HEADER FOREIGN KEY(MESSAGE_MAILBOX_ID,
MESSAGE_MAIL_UID) REFERENCES PUBLIC.JAMES_MAIL(MAILBOX_ID, MAIL_UID)";
SQL statement:
DELETE FROM PUBLIC.JAMES_MAIL t0 WHERE (t0.MAILBOX_ID = ?) [23503-154]
{prepstmnt 562850178 DELETE FROM PUBLIC.JAMES_MAIL t0 WHERE
(t0.MAILBOX_ID = ?) [params=?]} [code=23503, state=23503]
FailedObject: DELETE FROM PUBLIC.JAMES_MAIL t0 WHERE (t0.MAILBOX_ID =
?) [java.lang.String]
at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4869)
at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4829)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeBulkOperation(JDBCStoreQuery.java:579)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeDelete(JDBCStoreQuery.java:491)
at
org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeDelete(ExpressionStoreQuery.java:788)
at org.apache.openjpa.kernel.QueryImpl.delete(QueryImpl.java:1025)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:865)
at org.apache.openjpa.kernel.QueryImpl.deleteAll(QueryImpl.java:892)
at
org.apache.openjpa.kernel.DelegatingQuery.deleteAll(DelegatingQuery.java:574)
at
org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:362)
at
org.apache.james.mailbox.jpa.mail.JPAMailboxMapper.delete(JPAMailboxMapper.java:105)
... 76 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
Referential integrity constraint violation: "CONSTRAINT_9:
PUBLIC.JAMES_MAIL_JAMES_MAIL_HEADER FOREIGN KEY(MESSAGE_MAILBOX_ID,
MESSAGE_MAIL_UID) REFERENCES PUBLIC.JAMES_MAIL(MAILBOX_ID, MAIL_UID)";
SQL statement:
DELETE FROM PUBLIC.JAMES_MAIL t0 WHERE (t0.MAILBOX_ID = ?) [23503-154]
{prepstmnt 562850178 DELETE FROM PUBLIC.JAMES_MAIL t0 WHERE
(t0.MAILBOX_ID = ?) [params=?]} [code=23503, state=23503]
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:281)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:72)
at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1199)
at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:291)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1776)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeUpdate(JDBCStoreQuery.java:746)
at
org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeBulkOperation(JDBCStoreQuery.java:577)
... 84 more
Tests run: 30, Failures: 0, Errors: 30, Skipped: 0, Time elapsed:
3.332 sec<<< FAILURE!
It seems like it don't understand that it need to remove the "many"
mappings first....
Thanks,
Norman
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]