1、刚才在javaeye看到了robbin等人关于DomainModel的讨论。这里想总结一下做为笔记。呵呵[@more@]robbin总结的常用主流三种方式:一个实体类叫做Item,指的是一个拍卖项目 一个DAO接口类叫做ItemDao 一个DAO接口实现类叫做ItemDaoHibernateImpl 一个业务逻辑类叫做ItemManager(或者叫做ItemService) java代码: public class Item implements Serializable { private Long id= null; private int version;
2、 private String name; private Userseller; private String description; private MonetaryAmountinitialPrice; private MonetaryAmountreservePrice; private Date startDate; private Date endDate; private Set categorizedItems= new HashSet(); private Collection bids= new Array
3、List(); private BidsuccessfulBid; private ItemStatestate; private UserapprovedBy; private Date approvalDatetime; private Date created= new Date(); // getter/setter方法省略不写,避免篇幅太长 }java代码: public interface ItemDao { public ItemgetItemById(Long id); public Collection find
4、All(); public void updateItem(Itemitem); }ItemDao定义持久化操作的接口,用于隔离持久化代码。 java代码: public class ItemDaoHibernateImpl implements ItemDao extends HibernateDaoSupport { public ItemgetItemById(Long id) { return (Item) getHibernateTemplate().load(Item.class,id); } public Collection f