最新的、符合 JPA 的 GenericDAO 实现
我读了这篇文章:
http://www.ibm.com/developerworks /java/library/j-genericdao.html
几次,相信我明白它在说什么。然而,它已经有 4 年历史了,我有一个符合 JPA 的 Java 应用程序需要处理。另外,我看到Spring中有一个JPATemplate有一些很好的功能,但是Spring文档说它已经被弃用了!
有人能给我指出一个可靠的、现代的、符合 JPA 的、基于 Spring 的 GenericDAOImpl 工作示例吗?它代理一个接口以提供通用查找器执行?
I read this article:
http://www.ibm.com/developerworks/java/library/j-genericdao.html
several times and believe I understand what it is saying. However, it is 4 years old and I have a JPA compliant Java application to contend with. In addition, I see that there is a JPATemplate in Spring that has some good functionality, but the Spring documentation says it is already deprecated!
Can anybody point me to a solid, modern, JPA compliant, Spring based, working example of a GenericDAOImpl that proxies an Interface to provide generic finder execution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如今,JPA 2 本身已经成为 DAO 层的一个不错的实现,因为它的责任(或者契约,如果你愿意的话)与传统的“精心设计的”DAO 相同,即将业务逻辑与存储机制隔离。由此产生的一个重要含义是,只有在使用非 DBMS 存储(例如电子表格文件、Web 服务等)时,您可能才需要显式 DAO。
Nowadays JPA 2 in itself has become a decent implementation of a DAO layer since its responsibility (or contract if you wish) is the same as for the traditional "crafted" DAO, that is an isolation of a business logic from a storage mechanism. An important implication out of this is that you may need an explicit DAO only when working with non-DBMS storages like spreadsheet files, web-services, etc.
我创建了一个通用的 DAO,混合了我在 这个问题。我使用这两种方法: DDD:通用存储库和JPA实现模式:数据访问对象。
如果您认为可以改进,请随时发表评论/编辑。
I've created a generic DAO mixing different approaches that I shared on SO in this question. I use these 2 approaches: DDD: The Generic Repository and JPA implementation patterns: Data Access Objects.
Please feel free to comment/edit if you think it can be improved.