读书人

Unity3DHouse中顺利删除信息

发布时间: 2012-11-10 10:48:50 作者: rapoo

Unity3DHouse中成功删除信息

//在jsp页面传入的参数在Action类中调用deleteHouse方法,此方法由HouseDao类中声明。

public boolean deleteHouse(Integer id){
?? ?/* Long i = new Long(id);
?? ??? Long id1=(Long)id;
?????? Integer i=new Integer(id);
?? ???? Housinginfo house;
?? ??? ? tx=session.beginTransaction();
?? ??? ?? TbLiuyan?? liuyan=(TbLiuyan)session.get(TbLiuyan.class,id);
?? ??? ?? session.delete(liuyan);
?? ??? ?? */
?? ??? ? Query q = getSession().createQuery("delete Housinginfo WHERE houseId=?");
?? ??? ? q.setInteger(0, id);
?? ??? ? q.executeUpdate();
?? ??? ? return true;
?? ??? ?
?? ??? ?
?? ??? ?/*Session session = sessionFactory.openSession();?? ?
?? ?    Transaction tx = session.beginTransaction();?? ?
?? ?    String hqlDelete = "delete Customer where name = :ldName";?? ?
?? ?    int deletedEntities = s.createQuery( hqlDelete )?? ?
?? ?    .setString( "oldName", oldName )?? ?
?? ?    .executeUpdate();?? ?
?? ?    tx.commit();?? ?
?? ?    session.close();
?? ??? ?
?? ??? ?try{
?? ??? ??? ?house = (Housinginfo)this.getHibernateTemplate().load(Housinginfo.class,i);
?? ??? ??? ?this.getHibernateTemplate().delete(house);
?? ??? ?}catch(Exception e){
?? ??? ??? ?System.out.println("dao内删除房子信息异常!");
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?return true;
?? ??? ?*/
?? ?? }

读书人网 >编程

热点推荐