Hi all,

I have the following problem with CMP2.0 beans:

We are currently using the 'Instance per Transaction' container configuration, but we 
are trying to move to  a container with caching and commit option A.

I have the impression that JBoss does  not always handle the referential inegrity on 
the database correctly: We have table Parcel with a foreign key to table Dsp.
On EJB level, we have bean Parcel with a one-to-many relation to bean Dsp. There is a 
setDsp() and a getDsp() method in the Parcel bean to set or get the CMR relation.

I execute the following method in the Parcel bean (transaction attribute = 
'Required'). It sets a new value for the Dsp relation, and then removes the old Dsp 
entity

public void setNewDsp( DspLocal  newDsp) throws ... {
    DspLocal oldDsp = getDsp();
    setDsp(newDsp) ;
    oldDsp.remove() ;
}

When I look at the SQL statements received by mysql , I get the following sequence:

1. DELETE FROM dsp WHERE dsp_pk='testRemoveAndCache''
2. UPDATE parcel SET dsp_fk='testRemoveAndCache_2' WHERE  parcel_pk='...'
3. UPDATE dsp SET country_fk=null, business_partner_fk=null, dsp_type_fk=null, 
pin_process_fk=null WHERE dsp_pk='testRemoveAndCache'

I see two problems here: 
- The first statement is sent to mysql when executing the third line of code. The 
second and third statement should be sent to mysql first because the related code is 
executed first.  
This update fails because of fk-violation, because the second query should be executed 
first. 
- The third statement tries to update the Dsp entity that was removed in the first 
statement.

I have the impression that the remove() method is not included in the transaction.

When I go through the code with debugger I see that the update of Parcel is cached 
(there is no sql sent to mysql). Then, when removing the Dsp, the query is sent 
immediately to mysql. 

Does anyone have any idea. Is this a JBoss bug ? Am I missing some config ?

Some info:

I am using jboss-3.2.3 with mysql 4.0.18-standard, mysqlConnector 3.0.11 running on 
Redhad Linux 9

My datasource is configured with transaction isolation TRANSACTION_READ_COMMITTED


Container config:

    <container-configuration extends="Standard CMP 2.x EntityBean">
         <container-name>KPServer CMP 2.x EntityBean</container-name>
         <sync-on-commit-only>true</sync-on-commit-only>
      </container-configuration>


The 'Standard CMP 2.x EntityBean' config:
<container-configuration>
         <container-name>Standard CMP 2.x EntityBean</container-name>
         <call-logging>false</call-logging>
         <invoker-proxy-binding-name>entity-rmi-invoker</invoker-proxy-binding-name>
         <sync-on-commit-only>false</sync-on-commit-only>
         <insert-after-ejb-post-create>true</insert-after-ejb-post-create>
         <container-interceptors>
            org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor
            org.jboss.ejb.plugins.LogInterceptor
            org.jboss.ejb.plugins.SecurityInterceptor
            org.jboss.ejb.plugins.TxInterceptorCMT
            org.jboss.ejb.plugins.MetricsInterceptor
            org.jboss.ejb.plugins.EntityCreationInterceptor
            org.jboss.ejb.plugins.EntityLockInterceptor
            org.jboss.ejb.plugins.EntityInstanceInterceptor
            org.jboss.ejb.plugins.EntityReentranceInterceptor
            org.jboss.resource.connectionmanager.CachedConnectionInterceptor
            org.jboss.ejb.plugins.EntitySynchronizationInterceptor
            org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor
         </container-interceptors>
         <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>
         
<instance-cache>org.jboss.ejb.plugins.InvalidableEntityInstanceCache</instance-cache>
         
<persistence-manager>org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager</persistence-manager>
         
<locking-policy>org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock</locking-policy>
         <container-cache-conf>
            
<cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
            <cache-policy-conf>
               <min-capacity>50</min-capacity>
               <max-capacity>1000000</max-capacity>
               <overager-period>300</overager-period>
               <max-bean-age>600</max-bean-age>
               <resizer-period>400</resizer-period>
               <max-cache-miss-period>60</max-cache-miss-period>
               <min-cache-miss-period>1</min-cache-miss-period>
               <cache-load-factor>0.75</cache-load-factor>
            </cache-policy-conf>
         </container-cache-conf>
         <container-pool-conf>
            100
         </container-pool-conf>
         <commit-option>A</commit-option>
      </container-configuration>


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3838970#3838970

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3838970


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to