About Annotations-hebernate and JPA (Java Persistence API)

Source: Internet
Author: User

The JPA spec. Defines the JPA annotation in the package javax.persistenceHibernate isn't only implements JPA spec, but extends it to adds more features. So, Hibernate creates their own annotations which just extend the JPA annotation with the hibernate features, and put th ESE annotation inside the packageorg.hibernate.annotations

If There is no Hibernate specified features added for that JPA annotation (eg @OneToMany @ManyToOne and), Hibernate won't make that annotation in their package and you had to use org.hibernate.annotations these annotation from javax.persistence according to the JPA specification.

Normally, people would use JPA annotations until they come across a situation the requires to use hibernate features.

In one word: If you want to use hibernate with annotation, you must use some annotations in the package javax.persistence .  Extends:1,JPA (Java Persistence API) is the Java Persistence specification proposed by Sun. It provides Java developers with an object/relational mapping tool to manage relational data in Java applications. , and Hibernate is one of its implementations. In addition to hibernate, there are Eclipselink (formerly TopLink), OPENJPA, etc. to choose from, so one advantage of using JPA is that you can replace the implementation without having to change too much code.

2,hibernate as a JPA implementation, JPA annotations are already at the heart of Hibernate, and Hibernate provides only a few additions, not two sets of annotations. Hibernate support for JPA is sufficient, and JPA is recommended for use with Hibernate annotations.

About Annotations-hebernate and JPA (Java Persistence API)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.