Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package cn.sharek.bsg.machine.dao.impl; import cn.sharek.bsg.machine.dao.DMLDao; import org.hibernate.Session; import java.util.Collection; /** * @author Administrator */ public class DMLDaoImpl<T> implements DMLDao<T> { @Override public void save(T entity, Session session) throws Exception { session.save(entity); } @Override public void save(Collection<T> entities, Session session) throws Exception { int i = 0; //??? for (Object obj : entities) { session.save(obj); i++; //?? if (0 == i % 10) { session.flush();//? session.clear();// } } } @Override public void delete(T entity, Session session) throws Exception { session.delete(entity); } @Override public void update(T entity, Session session) throws Exception { session.update(entity); } @Override public void delete(Collection<T> entities, Session session) throws Exception { int i = 0; //??? for (Object obj : entities) { session.delete(obj); i++; //?? if (0 == i % 10) { session.flush();//? session.clear();// } } } }