title: Dirty Read in Hibernate
body: <p>CustomerType entity :</p>
  
  <pre><code>public class CustomerType implements java.io.Serializable {
  
  private Integer customerTypeId;
  private String customerDesc;
  private Set customerInfos = new HashSet(0);
  
  public CustomerType() {
  }
  
  public CustomerType(String customerDesc) {
      this.customerDesc = customerDesc;
  }
  
  public CustomerType(String customerDesc, Set customerInfos) {
      this.customerDesc = customerDesc;
      this.customerInfos = customerInfos;
  }
  
  public Integer getCustomerTypeId() {
      return this.customerTypeId;
  }
  
  public void setCustomerTypeId(Integer customerTypeId) {
      this.customerTypeId = customerTypeId;
  }
  .....................
  </code></pre>
  
  <p>CustomerType has one to many relationship with this entity</p>
  
  <pre><code>public class CustomerInfo implements java.io.Serializable {
  
  private Integer customerId;
  private CustomerType customerType;
  private String name;
      .................................
  </code></pre>
  
  <p>i've a this method in DaoImpl class</p>
  
  <pre><code> @Override
  public int save(Object object) {
      try{
          transaction = session.beginTransaction();
          session.saveOrUpdate(object);
          session.flush();
          transaction.commit();
          return 1;
      }catch (Exception e) {
          transaction.rollback();
          e.printStackTrace();// TODO: handle exception
          return 0;
      }
  }
  </code></pre>
  
  <p>and i call it while updating an object</p>
  
  <pre><code>public String updateCustomerType(){
      this.customertype = this.daoManager.findCustoType(Integer.parseInt(this.customerTypeID));
      this.customertype.setCustomerDesc(this.custoTypeDesc);
      this.daoManager.save(this.customertype);
  }
  </code></pre>
  
  <p>This method successfully updating the database, but while i display list of CustomerInfo which has relation to CustomerType, the CustomerType parameter in CustomerInfo is not udpated</p>
  
  <pre><code>org.hibernate.Query q = session.createQuery("select customerInfo from CustomerInfo customerInfo");
  return q.list();
  </code></pre>
  
  <p>What wrong with mine.,wait for your comment. Thank you,</p>