4 Replies Latest reply on Oct 30, 2009 11:37 AM by Jigar Gohil

    Urgent.....EJB3/Hibernate....

    Jigar Gohil Newbie


      Hi All,
      I am new to EJB3...and have got bit confused....
      as per my understanding EJB3 follows the JPA standard when it comes to persistence layer....right...?

      1) does it require any Other Persistence Provider when i am using EJB3...?

      2) If NO...and if want to use Hibernate which also follows the same persistence standard i.e JPA.....from an architecture perspective which one is better I mean using EJB3.0 only OR using EJB3+Hibernate....?

      Thank You....in Advance....

        • 1. Re: Urgent.....EJB3/Hibernate....
          Wolfgang Knauf Master

          Hi,

          1) nope, the one bundled with your application server is all you need, and basic code should not need to care about the JPA provider.

          2) EJB3 only is probably better, because your app is able to run on different app servers, and if the EJB standard is changed, your app will probably still work. But the more complex your app becomes, the more chance is that you need to work with the JPA layer directly...

          Hope this helps a bit

          Wolfgang

          • 2. Re: Urgent.....EJB3/Hibernate....
            Jigar Gohil Newbie

            Thanx Wolfgang,
            I got your point...but...
            talking about hibernate :It supports standardized Java Persistence and EJB 3.0 (JSR 220) object/relational mapping annotations + on top of that It has Hibernate-specific extension annotations for performance optimization and special mappings...right...?
            So wouldnt it be better to go with EJB + Hibernate...?

            Regards.

            • 3. Re: Urgent.....EJB3/Hibernate....
              Wolfgang Knauf Master

              Hi,

              this depends on your app. If it has support different servers, you should not use Hibernate.
              If you know that this app will never run on other servers than JBoss, you can use EJB3 and Hibernate (hoping that JBoss will never change the persistence provider).

              Probably bad things will happen, if you mix Hibernate and a JPA provider of another vendor ;-).

              Hope this helps

              Wolfgang

              • 4. Re: Urgent.....EJB3/Hibernate....
                Jigar Gohil Newbie

                Thanx Wolfgang...

                Obviosly...bad things can happen, if anyone mix Hibernate and a JPA provider of another vendor.... :)

                Today...I successfully...implemented and ran my first EJB3 Application with Struts 2 framework... & JBOSS 4.2.3GA as AS :)

                Although I developed it with very basic features of EJB3,struts2...it has raised few more questions in my mind...
                1) Dependency Injection didn't work in struts Action...why...?
                2) U said....The Application will require the JPA Provider bundled with application server...
                I didn't configure any Persistence provider in my Persistence.xml file...still the application worked...how..?

                Regards...