Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!t38g2000prj.googlegroups.com!not-for-mail From: lewbloch Newsgroups: comp.lang.java.programmer Subject: Re: Spring/hibernate and JDBC Date: Mon, 11 Jul 2011 11:25:48 -0700 (PDT) Organization: http://groups.google.com Lines: 49 Message-ID: References: <3c16e5e7-3c0b-4126-9dd9-88f372a58f03@e26g2000prf.googlegroups.com> NNTP-Posting-Host: 172.19.62.231 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1310408850 19271 127.0.0.1 (11 Jul 2011 18:27:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Jul 2011 18:27:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t38g2000prj.googlegroups.com; posting-host=172.19.62.231; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ASELCHRU X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6079 On Jul 9, 5:32=A0pm, Jack wrote: > On Jul 9, 4:01=A0pm, markspace <-@.> wrote: > > > On 7/9/2011 2:56 PM, Jack wrote: > > > > With spring and hibernate so popular now, is there anybody still only > > > use JDBC to write database application code? Thanks. > > > I'm sure someone is, but yes I assume that JPA & Hibernate and > > dependency injection frameworks like Spring and JSF have become the nor= m. > > > Still good to know what JDBC is and does, since it's used by JPA and > > Hibernate (et al.). > > Is using JDBC to access database more efficient than using > Spring/hibernate? Yes and no. It can be more efficient as a programmer to use Hibernate (but don't use Spring!), at least if you stay with the JPA-compliant parts of Hibernate. It can run more efficiently to use JDBC without JPA, but usually is not. Unfortunately, most use of Hibernate in the wild is quite ignorant and harms the respective projects. I have yet to encounter intelligent use of Spring in a real project. Good use of JPA will make your program quite clean and maintainable, i.e., very efficient in the development and maintenance dimensions. Bad use of JPA, like bad use of a chain saw, results in a horror-movie scenario. For certain bulk operations, JDBC is better. Asking about "efficiency" for use of JPA vs. JDBC calls is like asking if it's more efficient to use an automobile than a bicycle. The use cases differ, so where one is more appropriate the other is less so, and "efficiency" has little to nothing to do with it. That is to say, "efficiency with respect to what?" is your real question. So, efficiency with respect to what? Use JPA when you want to code to an object model that persists itself, without regard for the data-centric point of view. Use JDBC when you need a relational model of your persistent data. Eschew Spring. -- Lew