gdamour     2004/11/11 08:27:44

  Modified:    modules/openejb-builder/src/java/org/openejb/deployment
                        CMPContainerBuilder.java CMPEntityBuilder.java
  Log:

  GERONIMO-467: ejbRemove does not work for CMP with MTM relationship
  GERONIMO-468: CMP - cascade delete is not supported
  
  o update CMPRemoveMethod such that relationships are reset and EJB in
  cascade-delete relationships are also removed; and
  o update the way the various TranQL schema are built in order to retrieve
  the EJB defining a cascade-delete relationship.
  
  Revision  Changes    Path
  1.2       +8 -9      
openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPContainerBuilder.java
  
  Index: CMPContainerBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPContainerBuilder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CMPContainerBuilder.java  10 Nov 2004 01:35:08 -0000      1.1
  +++ CMPContainerBuilder.java  11 Nov 2004 13:27:44 -0000      1.2
  @@ -305,7 +305,7 @@
           }
   
           // build the vop table
  -        LinkedHashMap vopMap = buildVopMap(beanClass, cacheTable, 
cmp1Bridge, identityDefiner, ejb.getPrimaryKeyGeneratorDelegate(), 
primaryKeyTransform, localProxyTransform, remoteProxyTransform, queryCommands);
  +        LinkedHashMap vopMap = buildVopMap(beanClass, cacheTable, 
cmrFieldAccessors, cmp1Bridge, identityDefiner, 
ejb.getPrimaryKeyGeneratorDelegate(), primaryKeyTransform, localProxyTransform, 
remoteProxyTransform, queryCommands);
   
           InterfaceMethodSignature[] signatures = (InterfaceMethodSignature[]) 
vopMap.keySet().toArray(new InterfaceMethodSignature[vopMap.size()]);
           VirtualOperation[] vtable = (VirtualOperation[]) 
vopMap.values().toArray(new VirtualOperation[vopMap.size()]);
  @@ -356,9 +356,7 @@
           int offset = ejb.getAttributes().size();
           for (int i = offset; i < offset + associationEnds.size(); i++) {
               CMRField field = (CMRField) associationEnds.get(i - offset);
  -            if ( field.isVirtual() ) {
  -                continue;
  -            }
  +
               String name = field.getName();
               Association association = field.getAssociation(); 
               CMRField relatedField = (CMRField) 
association.getOtherEnd(field);
  @@ -396,7 +394,7 @@
                           
relatedEJB.getProxyFactory().getLocalInterfaceClass());
               }
   
  -            cmrFieldAccessors.put(field.getName(), accessor);
  +            cmrFieldAccessors.put(name, accessor);
           }
           return cmrFieldAccessors;
       }
  @@ -469,6 +467,7 @@
   
       protected LinkedHashMap buildVopMap(Class beanClass,
               CacheTable cacheTable,
  +            Map cmrFieldAccessors,
               CMP1Bridge cmp1Bridge,
               IdentityDefiner identityDefiner,
               PrimaryKeyGeneratorDelegate keyGenerator,
  @@ -536,16 +535,16 @@
   
                   // ejbObject.remove()
                   vopMap.put(new InterfaceMethodSignature("remove", false),
  -                        new CMPRemoveMethod(beanClass, signature));
  +                        new CMPRemoveMethod(beanClass, signature, 
cacheTable, cmrFieldAccessors));
   
                   // ejbHome.remove(primaryKey)
                   vopMap.put(new InterfaceMethodSignature("ejbRemove", new 
Class[]{Object.class}, true),
  -                        new CMPRemoveMethod(beanClass, signature));
  +                        new CMPRemoveMethod(beanClass, signature, 
cacheTable, cmrFieldAccessors));
   
                   // ejbHome.remove(handle)
                   Class handleClass = 
getClassLoader().loadClass("javax.ejb.Handle");
                   vopMap.put(new InterfaceMethodSignature("ejbRemove", new 
Class[]{handleClass}, true),
  -                        new CMPRemoveMethod(beanClass, signature));
  +                        new CMPRemoveMethod(beanClass, signature, 
cacheTable, cmrFieldAccessors));
               } else if (name.equals("ejbActivate")) {
                   vopMap.put(MethodHelper.translateToInterface(signature)
                           , EJBActivateOperation.INSTANCE);
  
  
  
  1.4       +8 -4      
openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPEntityBuilder.java
  
  Index: CMPEntityBuilder.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/openejb-builder/src/java/org/openejb/deployment/CMPEntityBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CMPEntityBuilder.java     10 Nov 2004 07:23:24 -0000      1.3
  +++ CMPEntityBuilder.java     11 Nov 2004 13:27:44 -0000      1.4
  @@ -391,6 +391,9 @@
           if ("One".equals(role.getMultiplicity().getStringValue())) {
               roleInfo.isOne = true;
           }
  +        if ( role.isSetCascadeDelete() ) {
  +            roleInfo.isCascadeDelete = true;
  +        }
           return roleInfo;
       }
   
  @@ -463,13 +466,13 @@
   
           boolean isVirtual = null == roleInfo[0].cmrFieldName;
           String endName = isVirtual ? "$VirtualEnd" + id : 
roleInfo[0].cmrFieldName;
  -        roleInfo[0].ejb.addCMRField(new CMRField(endName, roleInfo[1].ejb, 
roleInfo[1].isOne, relationship, isVirtual));
  -        roleInfo[0].table.addEndTable(new EndTable(endName, 
roleInfo[1].table, roleInfo[1].isOne, joinTable, isVirtual));
  +        roleInfo[0].ejb.addCMRField(new CMRField(endName, roleInfo[1].ejb, 
roleInfo[1].isOne, roleInfo[1].isCascadeDelete, relationship, isVirtual));
  +        roleInfo[0].table.addEndTable(new EndTable(endName, 
roleInfo[1].table, roleInfo[1].isOne, roleInfo[1].isCascadeDelete, joinTable, 
isVirtual));
   
           isVirtual = null == roleInfo[1].cmrFieldName;
           endName = isVirtual ? "$VirtualEnd" + id : roleInfo[1].cmrFieldName;
  -        roleInfo[1].ejb.addCMRField(new CMRField(endName, roleInfo[0].ejb, 
roleInfo[0].isOne, relationship, isVirtual));
  -        roleInfo[1].table.addEndTable(new EndTable(endName, 
roleInfo[0].table, roleInfo[0].isOne, joinTable, isVirtual));
  +        roleInfo[1].ejb.addCMRField(new CMRField(endName, roleInfo[0].ejb, 
roleInfo[0].isOne, roleInfo[0].isCascadeDelete, relationship, isVirtual));
  +        roleInfo[1].table.addEndTable(new EndTable(endName, 
roleInfo[0].table, roleInfo[0].isOne, roleInfo[0].isCascadeDelete, joinTable, 
isVirtual));
       }
   
       private Class getCMPFieldType(boolean cmp2, String fieldName, Class 
beanClass) throws DeploymentException {
  @@ -611,6 +614,7 @@
           private EJB ejb;
           private Table table;
           private boolean isOne;
  +        private boolean isCascadeDelete;
           private JoinDefinition ejbJDef;
           private JoinDefinition tableJDef;
           private RoleInfo(String entityName, String cmrFieldName) {
  
  
  

Reply via email to