1
CustomerType實體:髒讀處於休眠
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;
}
.....................
CustomerType有一個與此實體一對多關係
public class CustomerInfo implements java.io.Serializable {
private Integer customerId;
private CustomerType customerType;
private String name;
.................................
我有一個這種方法在DaoImpl類
@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;
}
}
和我在更新對象時稱它爲
public String updateCustomerType(){
this.customertype = this.daoManager.findCustoType(Integer.parseInt(this.customerTypeID));
this.customertype.setCustomerDesc(this.custoTypeDesc);
this.daoManager.save(this.customertype);
}
這種方法成功地更新數據庫,但是當我顯示CustomerInfo的列表,它有關係CustomerType,在CustomerInfo的CustomerType參數不udpated
org.hibernate.Query q = session.createQuery("select customerInfo from CustomerInfo customerInfo");
return q.list();
有什麼錯我的。,等待您的評論。謝謝,
等待您的解決方案, –
真的在等待你的解決方案。 –