6 Replies Latest reply on May 12, 2006 2:32 AM by Krzysztof Kowalski

    DAO-JDBC vs. EJB3

    Krzysztof Kowalski Newbie

      Hi,
      My company uses for persistance DAO-JDBC, but we are going to change it to EJB3. I have a question. Is EJB3 persistance performance as good as DAO-JDBC? I did some tests and they show that DAO-JDBC is better in reading data ten times. What do you think? Should we change our persistance engine?

      Thanks
      Chris

      ps. Sorry for mistakes.

        • 1. Re: DAO-JDBC vs. EJB3
          Kamil Dworakowski Newbie

          Better w8 till final release.

          • 2. Re: DAO-JDBC vs. EJB3
            Emmanuel Bernard Master

             

            "kowal7" wrote:
            Hi,
            My company uses for persistance DAO-JDBC, but we are going to change it to EJB3. I have a question. Is EJB3 persistance performance as good as DAO-JDBC? I did some tests and they show that DAO-JDBC is better in reading data ten times. What do you think? Should we change our persistance engine?

            Thanks
            Chris

            ps. Sorry for mistakes.


            http://www.hibernate.org/15.html

            • 3. Re: DAO-JDBC vs. EJB3
              Javid Jamae Newbie

               

              I did some tests and they show that DAO-JDBC is better in reading data ten times.


              Did you compare apples to apples? EJB3 doesn't just pull the raw data from the database, it maps the data into objects. You would have to create an object graph out of the ResultSet data you get back with your DAO in order to have a true comparison. Also, depending on your JDBC driver, JDBC may not actually pull in all the data until you iterate over the result set.

              The main reason to go with EJB3 is when you have a rich domain model and you want a simpler way to map object graphs into the database. It solves a complexity problem more than a performance problem. But performance can be optimized through different features that Hibernate provides (caching, join strategies, lazy loading, eager fetching, etc).

              You may want to learn a little more about OR mapping before you make a recommendation one way or another. I would suggest reading Hibernate in Action or taking a Hibernate course.

              • 4. Re: DAO-JDBC vs. EJB3
                Krzysztof Kowalski Newbie

                 

                Did you compare apples to apples? EJB3 doesn't just pull the raw data from the database, it maps the data into objects. You would have to create an object graph out of the ResultSet data you get back with your DAO in order to have a true comparison. Also, depending on your JDBC driver, JDBC may not actually pull in all the data until you iterate over the result set.

                Yes I did.

                The main reason to go with EJB3 is when you have a rich domain model and you want a simpler way to map object graphs into the database. It solves a complexity problem more than a performance problem. But performance can be optimized through different features that Hibernate provides (caching, join strategies, lazy loading, eager fetching, etc).

                I know that.

                You may want to learn a little more about OR mapping before you make a recommendation one way or another.

                I don't make recommendation. I have just asked.

                Pozd.

                • 5. Re: DAO-JDBC vs. EJB3
                  Atanas Todorov Newbie

                  The explanations provided in
                  http://www.hibernate.org/15.html and
                  http://www.hibernate.org/157.html
                  I find very comprehensive and substantial.

                  The issues related to performance have always been very easy to be misunderstood and wrongly interpreted...

                  I just want to mention that using DAO & JDBC forces you to work on a lower level, which means that you are less likely to do unnecessary things. When using additional layer (even the best ORM) it is often much easier to do "wrong" things that slow down the performance (like unnecessary eager collections & objects). But it does not mean that the problem is in the ORM itself. As a matter of fact, I am not too proficient in hibernate, but I think that it is pretty good at what it does.

                  So, I'd almost always prefer hibernate3/EJB3 (with annotations) to JDBC/DAO, because I find that these technologies have more pros than cons. As a comparison, I'll mention that I'd almost never prefer EJB2 persistence to JDBC/DAO...

                  • 6. Re: DAO-JDBC vs. EJB3
                    Krzysztof Kowalski Newbie

                    Thank you.
                    We are going to change DAO-JDBC to EJB3.