The Hibernate EntityManager documentation states, that:
You may use a combination of all three together, annotations without JPA programming inter
But would I have any advantages when using purely Hibernate Core?
If JPA 2.0 supports what you need, there is in my opinion no advantage at using Hibernate Core directly (and with JPA 2.0, the gap became more thin, making the need to fallback to Core the exception, not the rule, which is a very good thing).
I wonder, if the JPA 2 model really fits on top of Hibernate Core without any contradictions?
It does since JPA 1.0, the Hibernate developers created Hibernate3 with "JPA in mind" and adopted JPA semantics, defaults, etc in Hibernate3. You might want to listen to Gavin in this Tech Talk: Gavin King on Hibernate3 and EJB3:
In this tech talk King discusses how Hibernate3 builds upon and extends EJB3, addressing such topics as:
- New features of Hibernate3
- The relationship between Hibernate3 and the EJB3 container in JBoss
- What differentiates Hibernate3 from the EJB3 specification
- Hibernate's custom annotations available outside EJB
- The future of Hibernate
And according to my practical experience, the fact that Hibernate doesn't contradict with EJB 3 is true.
IOW, is a fallback to Core always easy and without problems?
Whether you use Core directly or not, you are using it (the EntityManager
is a wrapper around the Session
). So, yes, falling back to Core is easy if you really have to (for things that are still not in the spec like Query By Example, for example). And, no, this won't cause any problems (since you actually are using it, or a subset of it, in JPA).