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


Groups > comp.lang.java.help > #954

Re: Doing JDBC code in a less unwieldy way?

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.help
Subject Re: Doing JDBC code in a less unwieldy way?
References <j2javb$4pq$1@dont-email.me> <c59s47d0r3cq4380hepgq6vjab35aq8hs0@4ax.com>
Message-ID <Xes3q.40024$kI4.17217@newsfe02.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-08-19 08:59 -0300

Show all headers | View raw


On 11-08-19 06:00 AM, Roedy Green wrote:
> On Thu, 18 Aug 2011 11:26:34 -0400, Steve <tinker123@gmail.com> wrote,
> quoted or indirectly quoted someone who said :
> 
>> The place where I work isn't ready to go to a framework and something 
>> like a hibernate yet.
> 
> I think nearly everyone with the problem uses Hibernate. One advantage
> of going that route is are lots of people with Hibernate experience.
> 
> The other possible route is a stomper that cranks out the Java code
> you need from a specification. Much of the time the entire database
> structure is known at compile time, so you could create a class for
> each row returned, a use a cookie cutter to read the ResultSet and
> convert it into a class of that object with everything converted into
> binary fields: e.g. int, double, enum, String...
> 
> Your code looks just as if it would if you were very patient. It is
> just you have a way of cranking it out accurately, and modifying it
> easily if something should change. 
> 
> The advantage of this approach is someone who does not understand
> Hibernate can easily understand your code. It is also extremely light
> weight.
> 
I wouldn't try to gloss this over: like the others pointed out, for any
real-world situation all you end up doing is re-inventing the wheel.
What you suggest is not "extremely lightweight", although with some
automation (a la Lawrence d'Oliveiro's whizbang Python DB scripts) it
doesn't have to be awfully painful either. But by the time you're done
with the other basics, like foreign keys and other constraints, you used
a lot of time to accomplish a fraction of what a JPA provider will have
done for you. And anyone who thinks they can do a better job in a few
weeks than SMEs who've been working the problem for years is welcome to try.

The irony is that modern Java IDES with the right tooling and project
setups can point right at a DB and produce a customized set of JPA
entity classes, which is essentially what you are talking about here. So
not only are we thinking of re-inventing a chunk of JPA we are also
re-inventing IDE plugins.

Then throw in things like change tracking. JPA providers are good at
this, it's one of their selling features. It's also important (do you
really want to issue updates for every field in an object when just a
few change?), and it's hard to do. In the absence of JPA-type managed
object change tracking, your app logic needs to know what the expected
changes are (admittedly there are _some_ pros to this), and create the
right JDBC updates at the right time, but isn't that extra boilerplate
code also what the OP would like to avoid?

My advice to the OP is to try to convince his management. It's not like
these JPA providers are all unsupported pieces of software.

AHS

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


Thread

Doing JDBC code in a less unwieldy way? Steve <tinker123@gmail.com> - 2011-08-18 11:26 -0400
  Re: Doing JDBC code in a less unwieldy way? markspace <-@.> - 2011-08-18 08:57 -0700
    Re: Doing JDBC code in a less unwieldy way? Lew <lewbloch@gmail.com> - 2011-08-18 11:26 -0700
  Re: Doing JDBC code in a less unwieldy way? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-19 02:00 -0700
    Re: Doing JDBC code in a less unwieldy way? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-19 08:59 -0300
      Re: Doing JDBC code in a less unwieldy way? Lew <lewbloch@gmail.com> - 2011-08-19 07:57 -0700
      Re: Doing JDBC code in a less unwieldy way? Steve <tinker123@gmail.com> - 2011-08-19 19:50 -0400
        Re: Doing JDBC code in a less unwieldy way? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-19 21:26 -0300
          Re: Doing JDBC code in a less unwieldy way? Lew <lewbloch@gmail.com> - 2011-08-19 20:20 -0700
      Re: Doing JDBC code in a less unwieldy way? Roedy Green <see_website@mindprod.com.invalid> - 2011-08-20 17:19 -0700
        Re: Doing JDBC code in a less unwieldy way? Lew <lewbloch@gmail.com> - 2011-08-20 18:53 -0700
        Re: Doing JDBC code in a less unwieldy way? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-21 10:32 -0300
  Re: Doing JDBC code in a less unwieldy way? Ricardo Palomares Martínez <rpm.PUBLI@iespana.es> - 2011-08-20 13:07 +0200
    Re: Doing JDBC code in a less unwieldy way? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-20 10:59 -0300
      Re: Doing JDBC code in a less unwieldy way? Lew <lewbloch@gmail.com> - 2011-08-20 10:02 -0700
        Re: Doing JDBC code in a less unwieldy way? Ricardo Palomares Martínez <rpm.PUBLI@iespana.es> - 2011-08-21 16:03 +0200
      Re: Doing JDBC code in a less unwieldy way? Ricardo Palomares Martínez <rpm.PUBLI@iespana.es> - 2011-08-21 15:54 +0200
        Re: Doing JDBC code in a less unwieldy way? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-22 18:56 -0300

csiph-web