I am starting a normal Java SE project and i am planning to use 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)?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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:
Don't let Hibernate steal your identity and Generic Data Access Objects
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. This has worked out nicely for us.
回答2:
Here is the guide for using JPA with 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. We have worked with JDK 5 with heavily used annotations.