hibernatedao层的接口写法

需求: 现在要设计 3 个 DAO 分对 Wind, Horse, Cow 进行增、删、改以及一些其他操作。
第一种想法:
Public interface WindDao {
public void create(Wind obj);
public void delete(Wind obj);
public void update(Wind obj);

public void other(Wind obj);
}

Public interface HorseDao {
public void create(Horse obj);
public void delete(Horse obj);
public void update(Horse obj);

public void other(Horse obj);
}

Public interface CowDao {
public void create(Cow obj);
public void delete(Cow obj);
public void update(Cow obj);

public void other(Horse obj);
}
第二种想法:
Public interface BaseDao {
public void create(Object obj);
public void delete(Object obj);
public void update(Object obj);
}


Public interface WindDao extends BaseDao {
public void other(Wind obj);
}

Public interface HorseDao extends BaseDao {
public void other(Horse obj);
}

Public interface CowDao extends BaseDao {
public void other(Horse obj);
第三种:
public interface BaseDao {
public void create (T t);
public void delete (T t);
public void update (T t);
}

public interface WindDao extends BaseDao {
public void other (Wind wind);
}

你可能感兴趣的:(hibernate)