User: oberg   
  Date: 00/05/23 00:22:45

  Modified:    src/main/org/jboss/ejb/plugins/jaws
                        JAWSPersistenceManager.java
  Log:
  Fixed handling of null state and the dirtyFields bug
  
  Revision  Changes    Path
  1.4       +22 -19    
jboss/src/main/org/jboss/ejb/plugins/jaws/JAWSPersistenceManager.java
  
  Index: JAWSPersistenceManager.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/JAWSPersistenceManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JAWSPersistenceManager.java       2000/05/19 07:11:54     1.3
  +++ JAWSPersistenceManager.java       2000/05/23 07:22:45     1.4
  @@ -79,7 +79,7 @@
    *      
    *   @see <related>
    *   @author Rickard �berg ([EMAIL PROTECTED])
  - *   @version $Revision: 1.3 $
  + *   @version $Revision: 1.4 $
    */
   public class JAWSPersistenceManager
      implements EntityPersistenceManager
  @@ -731,31 +731,34 @@
            boolean[] dirtyField = new boolean[currentState.length];
            Object[] oldState = (Object[])ctx.getPersistenceContext();
            boolean dirty = false;
  -         ArrayList dirtyFields = new ArrayList();
            int refIdx = 0;
            for (int i = 0;i < currentState.length; i++)
            {
               if (((Integer)jdbcTypes.get(i)).intValue() == Types.REF)
               {
  -               if (!currentState[i].equals(oldState[i]))
  -               {
  -                  JawsCMPField[] pkFields = (JawsCMPField[])ejbRefs.get(refIdx);
  -                  for (int j = 0; j < pkFields.length; j++)
  -                  {
  -                     updateSql += (dirty?",":"") + 
((JawsCMPField)CMPFields.get(i)).getColumnName()+"_"+pkFields[j].getColumnName()+"=?";
  -                     dirty = true;
  -                  }
  -                  dirtyField[i] = true;
  -               }
  +                                     if (((currentState[i] != null) && 
  +                                                     (oldState[i] == null || 
!currentState[i].equals(oldState[i]))) ||
  +                                              (oldState[i] != null))
  +                                     {
  +                                        JawsCMPField[] pkFields = 
(JawsCMPField[])ejbRefs.get(refIdx);
  +                                        for (int j = 0; j < pkFields.length; j++)
  +                                        {
  +                                           updateSql += (dirty?",":"") + 
((JawsCMPField)CMPFields.get(i)).getColumnName()+"_"+pkFields[j].getColumnName()+"=?";
  +                                           dirty = true;
  +                                        }
  +                                        dirtyField[i] = true;
  +                                     }
                  refIdx++;
               } else
               {
  -               if (!currentState[i].equals(oldState[i]))
  -               {
  -                  updateSql += (dirty?",":"") + 
((JawsCMPField)CMPFields.get(i)).getColumnName()+"=?";
  -                  dirty = true;
  -                  dirtyField[i] = true;
  -               }
  +                                     if (((currentState[i] != null) &&
  +                                              (oldState[i] == null || 
!currentState[i].equals(oldState[i]))) ||
  +                                              (oldState[i] != null))
  +                                     {
  +                                        updateSql += (dirty?",":"") + 
((JawsCMPField)CMPFields.get(i)).getColumnName()+"=?";
  +                                        dirty = true;
  +                                        dirtyField[i] = true;
  +                                     }
               }
            }
            
  @@ -773,7 +776,7 @@
            
            int idx = 1;
            refIdx = 0;
  -         for (int i = 0;i < dirtyFields.size(); i++)
  +         for (int i = 0;i < dirtyField.length; i++)
            {
               if (((JawsCMPField)CMPFields.get(i)).getJdbcType().equals("REF"))
               {
  
  
  

Reply via email to