为什么你的DAO,也可以创建领域模型呢。 比如 public interface AccountDao { /** * this for login * @param username * @param password * @return Account or null */ Account getAccount(String username, String password); /** * this for service, not open * @param userId * @return account */ Account getAccount(String userId); Account getAccountByName(String username); Account getAccountByEmail(String email); void createAccount(Account account) throws Exception; void updateAccount(Account account) throws Exception; void deleteAccount(Account account) throws Exception; PageIterator getAccounts(int start, int count); } 在这里,Account不是领域模型吗,不是应该由Repository来创建嘛? 如果用Hibernate,一般DAO就返回POJO,在由Repository来返回domin model嘛? 看了JiveJdon的代码,我又觉的Hibernate有点多余。那我们用Hibernate来完成什么职责呢? 我们现在用的时候,只是讲数据局库字段,映射为一个对应的POJO,请BANG给我解释一下,谢谢
|
|