日期:2014-05-20 浏览次数:21143 次
public Cardinfo findById(Long id) { Session session = HibernateSessionFactory.getSession(); Transaction tx = null; Cardinfo cinfo = null; try { tx = session.beginTransaction(); cinfo = (Cardinfo) session.load(Cardinfo.class, id); tx.commit(); } catch (RuntimeException re) { tx.rollback(); log.error("==CardinfoServices findById failed==", re); } finally { session.close(); } return cinfo; }
String cidLoad = request.getParameter("cidLoad"); Cardinfo cardinfo = cardinfoSer.findById(new Long(cidLoad)); cardinfoForm.setCardid(new Long(cidLoad)); cardinfoForm.setCardname(cardinfo.getCardname()); cardinfoForm.setPhonenum(cardinfo.getPhonenum()); cardinfoForm.setCardstate(cardinfo.getCardstate()); cardinfoForm.setOtherinfo(cardinfo.getOtherinfo()); System.out.println("oid: " + cardinfo.getCardownerinfo().getOwnerid()); System.out.println("oid: " + cardinfo.getCardownerinfo().getOwnername());
public Cardinfo findById(Long id) { Session session = HibernateSessionFactory.getSession(); Transaction tx = null; Cardinfo cinfo = null; try { tx = session.beginTransaction(); cinfo = (Cardinfo) session.load(Cardinfo.class, id); Hibernate.initialize(cinfo); tx.commit(); } catch (RuntimeException re) { tx.rollback(); log.error("==CardinfoServices findById failed==", re); } finally { session.close(); } return cinfo; }