开发者

I am confused of Hibernate?

I learnt JPA for ORM. Now I am asked to use Hibernate as my provider. If I start 开发者_JS百科with Hibernate it is going down in different concept. Please say me How can I relate JPA and hibernate together. JPA reduces my Java code into simple code for persisting Objects. Now what does hibernate help JPA and what does it provide. Anyone please explain in simple.


As Pascal answered here

JPA is just an API. To use JPA, you need an implementation of this API and such implementations are called persistence providers (EcliseLink, Hibernate, OpenJPA)


Hibernate is not another concept; it is just one of many JPA implementations. Another would be EclipseLink. If you and the implementations keep to the specification then switching the implementation is just a matter of changing a couple of lines in your persistence.xml (e.g. the <provider> tag and implementation specific properties). At least in theory...


JPA is an API specification for persisting objects. It defines a SQL like query language, and annotations for defining entities and relationships.

Hibernate is an implementation of JPA that has various extensions as well as a legacy API and query language. As long as you don't use any of the extensions of Hibernate and stick with the JPA API you can more or less treat it interchangeably with other JPA implementations such as OpenJPA, TopLink etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜