java hibernate Criteria 删除数据 delete data 2种方法

	public String deleteByUserAccount(String account) {
    方式一:	
Session session = this.getCurrentSession(); Criteria criteria = session.createCriteria(SysUserC.class).add(Restrictions.eq("account", account)); Object object = criteria.uniqueResult(); if (object == null) { return null; } else { session.delete((SysUserC)object); return "SUCCESS"; } }
   方式二:
     Session session = this.getCurrentSession();String sql = "delete from sys_sms_log where mobile='" + account + "'";

        session.createSQLQuery(sql).executeUpdate();

 

你可能感兴趣的:(Hibernate)