-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Some basic questions about diff/co-existence of JPA and Hibe
PostPosted: Tue Dec 14, 2010 6:17 am 
Beginner
Beginner

Joined: Wed Oct 08, 2008 10:59 am
Posts: 37
I read now a couple of tutorials and would like to have some confirmation for the following statements:

1.) I can always use persistence implementations like Hiberate, OpenJPA, EclipseLink INDEPENDENTLY from JPA

2.) In ONE application I cannot use Hibernate over JPA and Hibernate directly (=without JPA).
Hibernate over JPA and Hibernate without JPA cannot co-exist in ONE program.

The developer must choose between one of them.

3.) If I use the persistence implementation Hibernate without JPA then hibernate.cfg.xml is used as configuration file.
If I use the persistence implementation Hibernate with JPA then persistence.xml is used as configuration file.

4.) If I use the persistence implementation Hibernate without JPA then always Hibernate Sessions are used.
If I use the persistence implementation Hibernate with JPA then always the Entity Manager is used.

5.) Which reasons could lead to a decision to use Hibernate WITHOUT JPA?

Peter


Top
 Profile  
 
 Post subject: Re: Some basic questions about diff/co-existence of JPA and Hibe
PostPosted: Wed Dec 15, 2010 5:57 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
1.) I can always use persistence implementations like Hiberate, OpenJPA, EclipseLink INDEPENDENTLY from JPA

Answering for Hibernate only the answer is yes, I'm not sure about the others.
JPA was inspired from Hibernate but Hibernate has it's own interface which provides more advanced features and flexibility; though I suspect that the other implementation's main goal is to implement JPA, not sure if they are adding more features to stay competitive.

Quote:
2.) In ONE application I cannot use Hibernate over JPA and Hibernate directly (=without JPA).
Hibernate over JPA and Hibernate without JPA cannot co-exist in ONE program.

Wrong, in fact many love to use both. When using Hibernate as JPA implementation you can use the JPA interface or get a reference to the Hibernate direct API, which would be the same engine as the JPA interface directly remaps methods to the hibernate implementation, so you can use both. Actually many projects use both annotations from hibernate and JPA, as JPA provides some of the base annotations but then often you might need the hibernate annotations to improve the mapping or enable other features not covered by the JPA specification.

Quote:
3.) If I use the persistence implementation Hibernate without JPA then hibernate.cfg.xml is used as configuration file.
If I use the persistence implementation Hibernate with JPA then persistence.xml is used as configuration file.

Yes, but all hibernate specific properties are picked up from persistence.xml too. It's nice to have a single configuration file. Actually for both cases there are many more options to configure it, including plain properties files and programmatic configuration (using just code, environment variable, ...).

Quote:
4.) If I use the persistence implementation Hibernate without JPA then always Hibernate Sessions are used.
If I use the persistence implementation Hibernate with JPA then always the Entity Manager is used.

If you don't have JPA, then you only have the option of Session. If you use JPA using Hibernate as implementation,
you can use either.
So many use the EntityManager as it's a more familiar API but then resort to using the Session directly for special
needs.

Quote:
5.) Which reasons could lead to a decision to use Hibernate WITHOUT JPA?

Usually people use JPA because they need: compliance, standards, possibility to switch implementation and
deployment container in case you ever find out another implementation is better - won't happen :)
Hibernate is always a step ahead in terms of innovation, it's way more powerful in terms
of features, mapping flexibility.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.