As far as I know Hibernate has two types of implementations
- implementation of JPA (2)(@Entity,@Table annotations)
- extension to older(conventional) hibernate (without JPA) ,HSQL queries are used, there is not annotation
If it is true, Why do we need second type of implementation while JPA is the ORM specification? If you can give API version while comparing them it could be better for me to understand the whole evaluation history of ORM? Thanks.
preguntado el 13 de enero de 13 a las 22:01
Hibernate was one of the first ORM tools, before the JPA specification. It was also developer before Java 5 (when annotations became available in Java), so everything used to be either XML configuration based, or XDoclet.
There was a big revamp of Java EE , which borrowed heavily from Spring and Hibernate, that introduced JPA but was also "generic" enough that you could plug in your own implementations.
There's no real difference in how hibernate works, just what mechanism you use to configure it. JPA annotations is now the standard, but you can still use XML only if you want.
No hay tal cosa como dos diferentes implementations of Hibernate - there's only one official implementation. You can either use Hibernate via annotations/JPA features or use Hibernate via explicit Hibernate classes; however the underlying Hibernate libraries will be the same.
JPA is just an interface which Hibernate (and other similar libraries) implement.
The history tells us that back in late nineties someone has invented EJB. The common consensus among Java community is that nobody liked it and many just used Hibernate or similar frameworks. This was until EJB 3.0 when persistence for EJBs was modelled pretty much according to how Hibernate works (note there are other types of beans in EJB, not only data mapping).
As far as i remember, annotations in Hibernate were introduced since version 3.2 or so; and i'm not talking about JPA annotations (javax.persistence package), but hibernate-specific annotations that can be found in hibernate-annotations package.
Almost everything you can do with hibernate-specific annotations, you can also do with JPA2 these days.
As it was said, JPA is just an interface and when you code to that interface, it'll be easier for you (at least in theory) to replace the underlying ORM provider to another one, like TopLink, OpenJPA or Eclipselink (if you need to)