问题描述
在通读this和'Repository vs Dao'之后,我对Spring Data JPA存储库的位置感到困惑。 在我的实现中,Spring Data JPA Repository中的此类存储库接口具有与数据库的隐藏技术连接。因此,它们不应该是DAO。参考资料告诉我,存储库中可能存在一些业务逻辑代码段。但是实现这种JpaRepository的存储库提供了非常简单的CRUD操作,而无需进行进一步的逻辑处理。以下代码段是通过一些业务逻辑判断从数据库中检索帐户的基本实现。所以这是我的问题。 AccountUtil类在软件层应该放在哪里? 应该在持久层还是业务层?
@H_404_3@@Component public class AccountUtil{ private AccountRepository repo; @Autowired public AccountUtil(AccountRepository repo){ this.repo = repo; } public Account getAccount(long id) throws AccountException{ Optional<Account> entity = repo.findById(id); if(entity.isPresent()){ return entity.get(); } else { throw new AccountException(); } } }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)