3 Replies Latest reply on Nov 16, 2009 8:59 AM by jaikiran

    JPA/EJB3 Entitybean/Hibernate JPA....Confused...

      I am confused with all the three things when it comes to an implementation...
      I took the following path...
      1) read JPA concepts
      2) read EJB3 Concepts
      3) developed the sample application with EJB3 & Jboss4.2.3GA....the application runs fine...even if i dont configure the Persistence Provider...
      4) read the Hibernate JPA concepts....and got confused...

      following is the bunch of questions i am having in my mind...
      1)when I am using EJB3 Entities...do i require PP...?
      2)if yes...how come my application ran without configuring a Persistence Provider(PP)...?
      3) can I develop an application's Persistence layer using only JPA...?
      4) when I saw a sample application on Hibernate JPA...It was same as my application except a configuration of Persistence provider as Hibernate...
      I mean Entities(POJOs with annotations) were same...both were using javax.persistence.EntityManager for persistence operations....
      so where the difference is laying between the application developed using EJB3 Entities & the one developed using Hibernate JPA....????


      Thanx in advance...

        • 1. Re: JPA/EJB3 Entitybean/Hibernate JPA....Confused...
          jaikiran

           

          1)when I am using EJB3 Entities...do i require PP...?

          Yes, a persistence provider is required. EJB3 and JPA are not the same. A persistence provider follows the JPA spec.

          2)if yes...how come my application ran without configuring a Persistence Provider(PP)...?


          JBoss internally uses Hibernate as the JPA Persistence provider, hence that's taken care of internally. Hmm, i was thinking this value was set globally at server level in JBOSS_HOME/server/< servername>/deployers/ejb3.deployer/META-INF/jpa-deployers-jboss-beans.xml, but i can't find it there. Anyway, if you are deploying in JBoss then the server will use Hibernate as the persistence provider. If you want to use some other persistence provider (like Toplink) then you will have to explicitly set that property in the persistence.xml

          3) can I develop an application's Persistence layer using only JPA...?

          Yes

          so where the difference is laying between the application developed using EJB3 Entities & the one developed using Hibernate JPA....????


          EJB3 Entities == JPA Entities. And JPA entities are managed by JPA persistence providers - Hibernate is just one such provider which manages those EJB3/JPA entities.


          • 2. Re: JPA/EJB3 Entitybean/Hibernate JPA....Confused...

            Thanx jaikiran...
            that was very heplful...
            It will be great if u can just help me out in finding the answers of following questions...

            1) wt additional/special features does hibernate provides if I want to use Hibernate JPA...?

            2) wt would be better the core Hibernate OR Hibernate JPA...? why?
            I mean obviously the standardization does gives an advantage of switching the PP anytime...but still have not explored the power of Core Hibernate fully...thats why have this question...

            Regards.

            • 3. Re: JPA/EJB3 Entitybean/Hibernate JPA....Confused...
              jaikiran

               

              "gohiljigar15" wrote:


              1) wt additional/special features does hibernate provides if I want to use Hibernate JPA...?

              I don't exactly know the list of such features. But each persistence provider including Hibernate have their own set of additional features. Most of the applications just use JPA since that covers almost everything that they require.

              "gohiljigar15" wrote:

              2) wt would be better the core Hibernate OR Hibernate JPA...? why?
              I mean obviously the standardization does gives an advantage of switching the PP anytime...but still have not explored the power of Core Hibernate fully...thats why have this question...



              I would recommend that you use JPA initially. Then as and when you feel the need for some Hibernate specific functionality, then you can think of using those.