Section 1. Starting a keen annotations enterprise
Hibernate, like all most other object/relational mapping units, demands metadata one governs the transformation of data from a single signal to the other. Hibernate Annotations brings annotation-centered mapping metadata.
This new JPA specs knows the eye together with popularity of the newest transparent target/relational mapping paradigm. It standardizes might APIs plus the metadata required for one object/relational effort device. Hibernate EntityManager executes the programming connects and you may lifecycle laws just like the laid out from the JPA effort specs and you will including Hibernate Annotations now offers a complete (and you may stand alone) JPA efforts provider on top of the mature Hibernate Key. You may use a mixture of most of the about three along with her, annotations in place of JPA programming interfaces and lifecycle, if you don’t natural native Hibernate Key, with respect to the team and technical demands of your own enterprise. At all time you could fall to Hibernate native APIs, or if perhaps needed, even so you can local JDBC and you can SQL.
Which release of Hibernate Annotations will be based upon the final release of the JPA dos specification (aka JSR-317) and you will supports the the has (including the elective of these). Hibernate certain features and you may extensions are also available because of unstandardized, Hibernate certain annotations.
What exactly is hibernate-jpa-2.0-api-x.y.z.container
This is basically the Container that features the new JPA dos.0 API, it’s completely certified on the spec and passed the new TCK trademark attempt. You usually do not require they when you deploy the application when you look at the a java EE 6 app host (eg JBoss Because 6 such as for instance).
I encourage you utilize Hibernate Validator together with Bean Recognition specs possibilities as the consolidation having Coffee Time and effort dos has been standardized. Install Hibernate Validator 4 otherwise a lot more than regarding Hibernate webpages and you can put hibernate-validator.container and you can validation-api.container in your classpath. Instead add the following the dependence on your pom.xml .
When you need to fool around with Hibernate Look, obtain they on the Hibernate web site and you may include hibernate-search.jar and its own dependencies on your own classpath. As an alternative range from the after the reliance on your own pom.xml .
We advice you utilize brand new JPA 2 APIs in order to bootstrap Hibernate (understand the Hibernate EntityManager records to learn more). When you use Hibernate Center and its particular local APIs continue reading.
For people who footwear Hibernate oneself, make sure to make use of the AnnotationConfiguration group instead of the Arrangement group. Here’s an illustration with the (legacy) HibernateUtil means:
Fascinating this is basically the entry to AnnotationConfiguration . The fresh new packages and you can annotated groups is actually proclaimed on your own normal XML setup document (usually hibernate.cfg.xml ). This is the exact carbon copy of the above mentioned report:
Remember that you might combine the latest history hbm.xml play with plus the annotation strategy. The newest money element can be either a keen hbm file otherwise an enthusiastic EJB3 XML implementation descriptor. The fresh change was transparent for your configuration processes.
There is no most other difference in making use of Hibernate APIs with annotations, with the exception of this startup the site regime alter or in the fresh arrangement document. You need to use your favorite configuration way for almost every other qualities ( , hibernate.cfg.xml , programmatic APIs, etc).
You could combine annotated persistent categories and you can antique hbm.cfg.xml elizabeth SessionFactory . You could potentially although not not declare a course once or twice (if annotated otherwise courtesy hbm.xml). You can’t merge setting procedures (hbm vs annotations) inside the an organization hierarchy either.
To help ease the latest migration techniques out-of hbm files in order to annotations, the fresh setup device finds this new mapping duplication anywhere between annotations and you may hbm documents. HBM data files is actually next prioritized more than annotated metadata towards the a category so you’re able to class foundation. You could potentially replace the priority playing with hibernate.mapping.precedence property. The new standard are hbm, class , modifying they to help you group, hbm commonly prioritize the newest annotated kinds more than hbm data whenever a great disagreement takes place.
step one.step 3. Attributes
Function accustomed provide the title of your own standard org.hibernate.annotations.CacheConcurrencyStrategy to use when possibly > is utilized. (strategy=”..”) is employed to bypass it standard.