简体   繁体   English

Java SE 6中的JPA / Hibernate,数据访问的最佳实践

[英]JPA/Hibernate in Java SE 6, Best Practices for data access

I am starting a normal Java SE project and i am planning to use JPA/Hibernate. 我正在开始一个普通的Java SE项目,我打算使用JPA / Hibernate。 I was wondering if anyone could enlighten me as to what is considered the best way to interact with Hibernate in this environment (data access layers)? 我想知道是否有人可以告诉我在这种环境(数据访问层)中与Hibernate交互的最佳方式是什么?

I'm not sure what's considered the best approach to this, but at my workplace, we have based most of our Hibernate interaction on these articles: 我不确定什么是最好的方法,但在我的工作场所,我们将大部分Hibernate交互基于这些文章:

Don't let Hibernate steal your identity and Generic Data Access Objects 不要让Hibernate窃取您的身份通用数据访问对象

They show you how to make your mapped classes in a smart way, and how to implement a generic DAO that can be reused for any persistent class. 它们向您展示了如何以智能方式创建映射类,以及如何实现可以为任何持久类重用的通用DAO。 This has worked out nicely for us. 这对我们很好。

Here is the guide for using JPA with Hibernate 以下是使用JPA和Hibernate的指南

We have used this approach in our application 1.5 years back and I do not think there is anything new in SE6 related to this. 我们在1.5年前的应用程序中使用了这种方法,我认为SE6中没有任何与此相关的新内容。 We have worked with JDK 5 with heavily used annotations. 我们使用了大量使用注释的JDK 5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM