泛型dao

public class BaseDao {
	public Session getSession(){
		return HibernateSessionFactory.getSessionFactory().getCurrentSession();
	}
}

public interface IDAO<T , PK extends Serializable> {
    public abstract void save(T entity);
    public abstract void update (T entity);
    public abstract void delete (T entity);
    public abstract  T findById(PK id);
    public abstract List<T> findAll();
}


public abstract class AbstractDAOImpl extends BaseDAO implements IDAO {

	public void delete(Object entity) {
		
	}

	public List findAll() {
	     return null;
	}

	public Object findById(Serializable id) {
		return null;
	}

	public void save(Object entity) {

	}

	public void update(Object entity) {
	
	}

}





public interface IRoomDAO<T,PK extends Serializable> extends IDAO {
      public abstract void save(List<T> listEntity); 
}




public class UserDAOImpl extends AbstractDAOImpl {

	public void save(User user) {
		
	}

	public void delete(Object entity) {
		
	}

	public List findAll() {
          	return null;
	}

	public Object findById(Serializable id) {
		return null;
	}

	public void save(Object entity) {
		
	}

	public void update(Object entity) {
	}

}





public class RoomDAOImpl extends AbstractDAOImpl implements IRoomDAO  {
   public void save(List lstRoom) {
	   
   }
}



public class BookDAOImpl extends AbstractDAOImpl {

	
	public void save(Object entity) {
		
	}

	public void update(Object entity) {
		
	}

}



你可能感兴趣的:(java,DAO)