3 Replies Latest reply on Oct 24, 2008 2:08 PM by swathi samala

    Why null values are stored on calling persist method

    swathi samala Newbie

      Hi all, I have created an xhtml file, entity class,bean class and wrote an action class for it, but when I click on save null values are getting stored in database, can any body tell me what mistake did I do..... here  is my action class...


      CustomerHome.java


       package com.manam.mewe.agile.pms.customer;
      
      import java.io.Serializable;
      
      import org.jboss.seam.annotations.Begin;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.web.RequestParameter;
      import org.jboss.seam.framework.EntityHome;
      
      import com.manam.mewe.agile.pms.data.DoCustomer;
      import com.manam.mewe.agile.pms.entity.ccr.Customer;
      
      
      @Name("customerHome")
      public class CustomerHome extends EntityHome<Customer> implements Serializable{
      
           @RequestParameter
           String customercustId;
           
           private static final long serialVersionUID = 7256951482186187096L;
           
           @In(create=true)
           DoCustomer doCustomer;
           
           @Override @Begin(join=true)
          public void create() {
              super.create();
          }
           
           public String persist(){
              return super.persist();
          }
           
           
           @Override
           public Object getId() {
                if (customercustId == null) {
                     return super.getId();
                } else {
                     return customercustId;
                }
           }
           
           
           
      }



        • 3. Re: Why null values are stored on calling persist method
          swathi samala Newbie

          I have changed the code even its storing null values....
          I need help please....



           package com.manam.mewe.agile.pms.customer;
          
          import java.io.Serializable;
          
          import org.apache.commons.beanutils.BeanUtils;
          import org.jboss.seam.annotations.Begin;
          import org.jboss.seam.annotations.In;
          import org.jboss.seam.annotations.Name;
          import org.jboss.seam.annotations.web.RequestParameter;
          import org.jboss.seam.framework.EntityHome;
          import org.jboss.seam.security.Identity;
          
          import com.manam.mewe.agile.pms.data.DoCustomer;
          import com.manam.mewe.agile.pms.entity.ccr.Customer;
          
          
          @Name("customerHome")
          public class CustomerHome extends EntityHome<Customer> implements Serializable{
          
               @RequestParameter
               String customercustId;
               
               @In Identity identity;
               
               private static final long serialVersionUID = 7256951482186187096L;
               
               @In(create=true)
               DoCustomer doCustomer;
               
               @Override @Begin(join=true)
              public void create() {
                     super.create();
                  try{
                          BeanUtils.copyProperties(doCustomer, getInstance());
                     }catch(Exception ee){
                          ee.printStackTrace();
                     }
                    
              }
               
               public String persist(){
                 
                 try{
                         BeanUtils.copyProperties(getInstance(), doCustomer);
                    }catch(Exception f){
                         f.printStackTrace();
                    }
                    super.persist();
                 return "done";
              }
               
               
               @Override
               public Object getId() {
                    if (customercustId == null) {
                         return super.getId();
                    } else {
                         return customercustId;
                    }
               }
               
                    
          }