geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Andrushchak <us...@dekasoft.com.ua>
Subject Re: CMP cascade deletation
Date Tue, 17 Jan 2006 11:51:13 GMT
Thank You Gianny!

It works. :-)

Best regards,
Alex Andrushchak

Gianny Damour wrote:

> Hi Alex,
>
> By default, JDBC commands are executed in an unspecified order. In 
> your case, this is an issue as JDBC commands need to be ordered such 
> that foreign key constraints are not violated. You can enable this 
> behaviour by declaring the <enforce-foreign-key-constraints> element 
> just after the <cmp-connection-factory> element in openejb-jar.xml 
> (you can find the XSD in schema/openejb-jar-2.0.xsd).
>
> Thanks,
> Gianny
>
> Alex Andrushchak wrote:
>
>> Hi!
>>
>> I have some relation declared with cascade deletation in my 
>> ejb-jar.xml, eg:
>>      <ejb-relation>
>>        <ejb-relation-name>Customer-Note</ejb-relation-name>
>>        <ejb-relationship-role>
>>          
>> <ejb-relationship-role-name>Customer-has-a-Note</ejb-relationship-role-name>

>>
>>          <multiplicity>One</multiplicity>
>>          <relationship-role-source>
>>            <ejb-name>CustomerEJB</ejb-name>
>>          </relationship-role-source>
>>          <cmr-field>
>>            <cmr-field-name>note</cmr-field-name>
>>          </cmr-field>
>>        </ejb-relationship-role>
>>        <ejb-relationship-role>
>>          
>> <ejb-relationship-role-name>Note-belongs-to-Customer</ejb-relationship-role-name>

>>
>>          <multiplicity>One</multiplicity>
>>          <cascade-delete/>
>>          <relationship-role-source>
>>            <ejb-name>NoteEJB</ejb-name>
>>          </relationship-role-source>
>>        </ejb-relationship-role>
>>      </ejb-relation>
>>
>> My database schema for this relation is:
>> CREATE TABLE customer (
>>    id integer NOT NULL,
>>    note_id integer,
>>    lastname character varying,
>>    confident boolean,
>>    middlename character varying,
>>    firstname character varying,
>>    location character varying
>> );
>>
>> ALTER TABLE ONLY customer
>>    ADD CONSTRAINT customer_pkey PRIMARY KEY (id);
>>
>> CREATE TABLE note (
>>    id integer NOT NULL,
>>    text character varying
>> );
>>
>> ALTER TABLE ONLY note
>>    ADD CONSTRAINT note_pkey PRIMARY KEY (id);
>>
>> ALTER TABLE customer
>>    ADD CONSTRAINT fk_customer_note FOREIGN KEY (note_id)
>>       REFERENCES note (id);
>>
>> openejb-jar.xml relation definition is:
>>        <ejb-relation>
>>            <ejb-relationship-role>
>>                <relationship-role-source>
>>                    <ejb-name>CustomerEJB</ejb-name>
>>                </relationship-role-source>
>>                <cmr-field>
>>                    <cmr-field-name>note</cmr-field-name>
>>                </cmr-field>
>>                <foreign-key-column-on-source/>
>>                <role-mapping>
>>                    <cmr-field-mapping>
>>                        <key-column>id</key-column>
>>                        <foreign-key-column>note_id</foreign-key-column>
>>                    </cmr-field-mapping>
>>                </role-mapping>
>>            </ejb-relationship-role>
>>        </ejb-relation>      When  i try to delete customer record 
>> container reporets error:
>> 11:21:38,156 ERROR [AbstractTransactionContext] Unable to roll back 
>> transaction
>> java.lang.IllegalStateException: Status is STATUS_NO_TRANSACTION
>>        at 
>> org.apache.geronimo.transaction.manager.TransactionImpl.rollback(Tran
>> sactionImpl.java:438)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .rollbackAndThrow(InheritableTransactionContext.java:308)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .complete(InheritableTransactionContext.java:199)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .commit(InheritableTransactionContext.java:146)
>>        at 
>> org.apache.geronimo.transaction.context.OnlineUserTransaction.commit(
>> OnlineUserTransaction.java:80)
>>        at 
>> org.queryphone.web.QueryphoneBaseAction.execute(QueryphoneBaseAction.
>> java:67)
>>        at 
>> org.apache.struts.action.RequestProcessor.processActionPerform(Reques
>> tProcessor.java:419)
>>        at 
>> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
>> va:224)
>>        at 
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
>> 4)
>>        at 
>> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>>        at 
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428
>> )
>>        at 
>> org.apache.geronimo.jetty.JettyServletHolder.handle(JettyServletHolde
>> r.java:99)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(
>> WebApplicationHandler.java:830)
>>        at 
>> org.mortbay.jetty.servlet.JSR154Filter.doFilter(JSR154Filter.java:170
>> )
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(
>> WebApplicationHandler.java:821)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
>> onHandler.java:471)
>>        at 
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
>> 68)
>>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
>> Context.java:633)
>>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
>>        at org.mortbay.http.HttpServer.service(HttpServer.java:909)
>>        at 
>> org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
>>        at 
>> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
>>        at 
>> org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
>>        at 
>> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
>> 244)
>>        at 
>> org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
>>        at 
>> org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
>> javax.transaction.SystemException: Unable to commit container 
>> transaction
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .rollbackAndThrow(InheritableTransactionContext.java:327)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .complete(InheritableTransactionContext.java:199)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .commit(InheritableTransactionContext.java:146)
>>        at 
>> org.apache.geronimo.transaction.context.OnlineUserTransaction.commit(
>> OnlineUserTransaction.java:80)
>>        at 
>> org.queryphone.web.QueryphoneBaseAction.execute(QueryphoneBaseAction.
>> java:67)
>>        at 
>> org.apache.struts.action.RequestProcessor.processActionPerform(Reques
>> tProcessor.java:419)
>>        at 
>> org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
>> va:224)
>>        at 
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:119
>> 4)
>>        at 
>> org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
>>        at 
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428
>> )
>>        at 
>> org.apache.geronimo.jetty.JettyServletHolder.handle(JettyServletHolde
>> r.java:99)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(
>> WebApplicationHandler.java:830)
>>        at 
>> org.mortbay.jetty.servlet.JSR154Filter.doFilter(JSR154Filter.java:170
>> )
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(
>> WebApplicationHandler.java:821)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicati
>> onHandler.java:471)
>>        at 
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:5
>> 68)
>>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
>>        at 
>> org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplication
>> Context.java:633)
>>        at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
>>        at org.mortbay.http.HttpServer.service(HttpServer.java:909)
>>        at 
>> org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
>>        at 
>> org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
>>        at 
>> org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
>>        at 
>> org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
>> 244)
>>        at 
>> org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
>>        at 
>> org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
>> Caused by: org.tranql.ql.QueryException: Error executing statement: 
>> DELETE FROM
>> note WHERE id = ?
>>        at 
>> org.tranql.sql.jdbc.JDBCUpdateCommand.execute(JDBCUpdateCommand.java:
>> 69)
>>        at 
>> org.tranql.cache.SimpleFlushStrategy.flush(SimpleFlushStrategy.java:6
>> 6)
>>        at 
>> org.tranql.cache.SimpleFlushStrategy.flush(SimpleFlushStrategy.java:4
>> 9)
>>        at 
>> org.tranql.cache.cache.InTxCacheTracker.flush(InTxCacheTracker.java:4
>> 1)
>>        at org.tranql.cache.InTxCache.flush(InTxCache.java:86)
>>        at 
>> org.apache.geronimo.transaction.context.AbstractTransactionContext.fl
>> ushState(AbstractTransactionContext.java:115)
>>        at 
>> org.apache.geronimo.transaction.context.InheritableTransactionContext
>> .complete(InheritableTransactionContext.java:175)
>>        ... 26 more
>> Caused by: org.postgresql.util.PSQLException: ERROR: update or delete 
>> on "note"
>> violates foreign key constraint "fk_customer_note" on "customer"
>>
>>        at 
>> org.postgresql.util.PSQLException.parseServerError(PSQLException.java
>> :139)
>>        at 
>> org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:152)
>>        at 
>> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:100)
>>        at 
>> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
>>        at 
>> org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stat
>> ement.java:517)
>>        at 
>> org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat
>> ement.java:50)
>>        at 
>> org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdb
>> c1Statement.java:273)
>>        at 
>> org.tranql.connector.jdbc.PreparedStatementHandle.executeUpdate(Prepa
>> redStatementHandle.java:103)
>>        at 
>> org.tranql.sql.jdbc.JDBCUpdateCommand.execute(JDBCUpdateCommand.java:
>>
>> What's wrong with it?
>>
>> Best regards,
>> Alex Andrushchak
>>
>>
>>
>
>
>


Mime
View raw message