日期:2014-05-20 浏览次数:20710 次
ackage per.ssh.dao.Admin; /** * Admin entity. @author MyEclipse Persistence Tools */ public class Admin implements java.io.Serializable { // Fields private String adminUser; private String adminPwd; private Integer adminLevel; // Constructors /** default constructor */ public Admin() { } /** full constructor */ public Admin(String adminUser, String adminPwd, Integer adminLevel) { this.adminUser = adminUser; this.adminPwd = adminPwd; this.adminLevel = adminLevel; } // Property accessors public String getAdminUser() { return this.adminUser; } public void setAdminUser(String adminUser) { this.adminUser = adminUser; } public String getAdminPwd() { return this.adminPwd; } public void setAdminPwd(String adminPwd) { this.adminPwd = adminPwd; } public Integer getAdminLevel() { return this.adminLevel; } public void setAdminLevel(Integer adminLevel) { this.adminLevel = adminLevel; } }
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="per.ssh.dao.Admin.Admin" table="admin" schema="dbo" catalog="mpr"> <id name="adminUser" type="java.lang.String"> <column name="admin_user" length="50" /> <generator class="assigned" /> </id> <property name="adminPwd" type="java.lang.String"> <column name="admin_pwd" length="50" not-null="true" /> </property> <property name="adminLevel" type="java.lang.Integer"> <column name="admin_level" not-null="true" /> </property> </class> </hibernate-mapping>
public void deleteByIds(final Object[] ids)throws DAOException{ for(int i=0;i<ids.length;i++){ System.out.println(ids[i]); } final String queryString="delete Admin where adminUser in (:ids)"; try{ this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) { Query query = session.createQuery(queryString); query.setParameterList("ids", ids); return query.executeUpdate(); } }); } catch(Exception ex){ throw new DAOException(ex); } /*for(int i=0;i<ids.length;i++){ try{ Admin admin=(Admin)this.getHibernateTemplate().get(Admin.class,ids[i]); if(admin!=null){ this.getHibernateTemplate().delete(admin); } } catch(Exception ex){ throw new DAOException(ex); } }*/ }