1. 批量 delete 和 save
public void deleteAllData() {
List l=this.getHibernateTemplate().find("from SchedulerSeq");
if(l!=null && l.size()>0)
this.getHibernateTemplate().deleteAll(l);
}
public void saveAll(List<BusBatIn> batinList) {
this.getHibernateTemplate().saveOrUpdateAll(batinList);
}
执行函数
public void callSaveBusStatus(Date lastTime) {
Connection con=this.getSession().connection();
PreparedStatement st = null;
try {
if(lastTime==null){
st = con.prepareStatement("select savet_vehicle_status(?) from Dual ");
st.setString(1,BusConstant.VEHICLE_BUS);
}else{
st = con.prepareStatement("select savet_vehicle_status(?,?) from Dual ");
st.setTimestamp(1,java.sql.Timestamp.valueOf(String.valueOf(lastTime)));
st.setString(2,BusConstant.VEHICLE_BUS);
}
st.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try{
if(st != null){
st.close();
}
} catch (Exception e) {
st = null;
}
try{
if(con != null){
con.close();
}
} catch (Exception e) {
con = null;
}
}
}