Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #6094

Re: Spring/hibernate and JDBC

From lewbloch <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Spring/hibernate and JDBC
Date 2011-07-11 17:06 -0700
Organization http://groups.google.com
Message-ID <269aaa9f-c097-439c-a499-f944635ed2f1@d8g2000prf.googlegroups.com> (permalink)
References <3c16e5e7-3c0b-4126-9dd9-88f372a58f03@e26g2000prf.googlegroups.com> <ivamk9$dph$1@dont-email.me> <a8ce2398-e1f7-4dfd-966e-48e8daa03416@p10g2000prf.googlegroups.com> <a82cc215-f2a4-4366-8e4d-e5f4ed5a70b2@t38g2000prj.googlegroups.com> <a029a3e5-83e9-4929-8fa4-5579972b4ce7@h25g2000prf.googlegroups.com>

Show all headers | View raw


On Jul 11, 4:39 pm, Jack <junw2...@gmail.com> wrote:
> Certainly using spring [sic]/hibernate [sic] has a shorter development circle than
> JDBC and the code is easier to maintain.

Not in my experience.  Badly written Spring code, which is all I've
ever seen, is terribly difficult, lengthy and expensive to maintain.
Badly written Hibernate code, which I have seen, likewise.  The
majority of Hibernate code I've seen (across several projects that
used it) was all badly written.  The problem came about with Hibernate
because people used it in lieu of SQL (i.e., raw JDBC calls) rather
than to support an object model.

> Here for efficiency, I mean performance. For a server with frequent
> and large amount of database accesses(insert/delete/update), which way
> has a better performance?

That depends, and has been answered upthread.  Properly used, JPA-
based code (including Hibernate) can be faster than raw JDBC,
depending on the use patterns.  Only you can answer this question.  We
cannot, based on the paucity of information you provide about your
scenario(s).  Your question is like asking, "Which relieves pain
better, aspirin or acetaminophen/codeine?"  The answer depends on the
problem you're trying to solve.

The question you should be asking is which one suits your logic
better.  Do you need to maintain an object model that must persist?
Chances are that Hibernate is useful and will help you - IF YOU KNOW
WHAT YOU'RE DOING!  If you don't, neither Hibernate nor JDBC can save
you.

The key is that JPA (don't use "native" Hibernate!) supports an object-
oriented model; JDBC supports a set-oriented model.  When set
operations are needed, JPA gets in the way.  When object-oriented
operations are needed, JDBC gets in the way.  Use what's right for the
problem.  You will never (NEVER!) get a reliable answer to "which has
better performance?" unless you write your code correctly (!),
appropriately to the programming model and MEASURE the performance.

Development and maintenance costs are more important than tiny
differences in runtime cost.  You might find that there is no
measurable difference at runtime.  Code correctly first, and only
address performance in the face of a demonstrated bottleneck.

Stop repeating your question until you've assimilated the good answers
you've already received, please.

--
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Spring/hibernate and JDBC Jack <junw2000@gmail.com> - 2011-07-09 14:56 -0700
  Re: Spring/hibernate and JDBC markspace <-@.> - 2011-07-09 16:01 -0700
    Re: Spring/hibernate and JDBC Jack <junw2000@gmail.com> - 2011-07-09 17:29 -0700
      Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:55 -0400
    Re: Spring/hibernate and JDBC Jack <junw2000@gmail.com> - 2011-07-09 17:32 -0700
      Re: Spring/hibernate and JDBC Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-10 08:27 -0300
      Re: Spring/hibernate and JDBC Aéris <aeris@imirhil.fr> - 2011-07-10 13:33 +0200
      Re: Spring/hibernate and JDBC lewbloch <lewbloch@gmail.com> - 2011-07-11 11:25 -0700
        Re: Spring/hibernate and JDBC Aéris <aeris@imirhil.fr> - 2011-07-11 20:44 +0200
        Re: Spring/hibernate and JDBC Jack <junw2000@gmail.com> - 2011-07-11 16:39 -0700
          Re: Spring/hibernate and JDBC lewbloch <lewbloch@gmail.com> - 2011-07-11 17:06 -0700
            Re: Spring/hibernate and JDBC Gene Wirchenko <genew@ocis.net> - 2011-07-11 21:37 -0700
          Re: Spring/hibernate and JDBC Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-12 07:01 -0300
          Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 18:00 -0400
        Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:58 -0400
          Re: Spring/hibernate and JDBC Tom Anderson <twic@urchin.earth.li> - 2011-07-22 17:24 +0100
      Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:52 -0400
    Re: Spring/hibernate and JDBC Tom Anderson <twic@urchin.earth.li> - 2011-07-10 13:34 +0100
      Re: Spring/hibernate and JDBC Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-10 11:08 -0300
        Re: Spring/hibernate and JDBC Stanimir Stamenkov <s7an10@netscape.net> - 2011-07-10 17:45 +0300
          Re: Spring/hibernate and JDBC Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-10 17:35 -0300
      Re: Spring/hibernate and JDBC Steve Sobol <sjsobol@JustThe.net> - 2011-07-10 09:42 -0700
    Re: Spring/hibernate and JDBC Tom <tom400f@gmail.com> - 2011-07-10 22:29 +0000
    Re: Spring/hibernate and JDBC Gunter Herrmann <notformail0106@earthlink.net> - 2011-07-11 10:19 -0400
      Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 18:09 -0400
  Re: Spring/hibernate and JDBC Aéris <aeris@imirhil.fr> - 2011-07-10 13:24 +0200
    Re: Spring/hibernate and JDBC Elegie <elegie@anonymous.invalid> - 2011-07-10 13:56 +0200
      Re: Spring/hibernate and JDBC Aéris <aeris@imirhil.fr> - 2011-07-10 14:17 +0200
  Re: Spring/hibernate and JDBC Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-10 10:44 -0300
  Re: Spring/hibernate and JDBC Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2011-07-11 09:52 +0300
  Re: Spring/hibernate and JDBC lewbloch <lewbloch@gmail.com> - 2011-07-11 11:31 -0700
    Re: Derby and Java SE (was: Spring/hibernate and JDBC) lewbloch <lewbloch@gmail.com> - 2011-07-11 15:46 -0700
  Re: Spring/hibernate and JDBC iadb <freeinternetarticles@gmail.com> - 2011-07-17 10:17 -0700
  Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:47 -0400
  Re: Spring/hibernate and JDBC Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 18:02 -0400

csiph-web