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


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

Re: Apache JDBC utils

From Jan Burse <janburse@fastmail.fm>
Newsgroups comp.lang.java.programmer
Subject Re: Apache JDBC utils
Date 2012-05-02 12:22 +0200
Organization albasani.net
Message-ID <jnr1u1$6g8$1@news.albasani.net> (permalink)
References <jnn1pc$33c$1@dont-email.me>

Show all headers | View raw


markspace schrieb:
> And: is there a better, light-weight non-ORM package that you might
> recommend instead? Something a bit more complete.

The example that you have posted involves a lot of classes.
You can build a framework that exposes only one class
XXXBean per table XXX, and that features bulk update,
delete and select, which you usually don't get via ORM,
or where you usually bypass the ORM.

The idea is as follows:
   - bulk update: Objects are not loaded, bean is just
       a facade to an SQL updates statement. No DB
       client roundtrips.
   - bulk delete: Objects are not loaded, bean is just
       a facade to an SQL delete statement. No DB
       client roundtrips.
   - bulk select: Only one object is loaded at a time,
       but the same object holder is reused, bean is
       just a facade to a SQL select statement and a
       cursor.

The idea shares the same benefits with an ORM:
   - possibility to have application specific column
     names and types.
   - transparent dealing with SQL dialects, i.e.
     issues such as boolean representation, string
     encoding etc...
   - Since colums correspond to methods, its easy
     to find usages in your application, i.e. cross
     referencing
   - Since columns correspond to methods, and these
     have types, it is easy to find compilation erros,
     i.e. wrong type use of columns etc..

So how will the API of such a XXXBean look like. Well
it will have the following methods:

   whereYYY(TTT);   Establish condition on column YYY
   calcYYY(TTT);    Establish value on column YYY
   TTT getYYY();    Retrieve value of column YYY
   list();          Open cursor
   next();          Advance cursor
   close();         Close cursor
   update();        Bulk update
   insert();        Single insert
   delete();        Bulk delete

For CRUD the API is used as follows:

                    C      R      U     D
   whereYYY(TTT);   -      x      x     x
   calcYYY(TTT);    x      -      x     -
   getYYY();        -      x      -     -
   list();          -      x      -     -
   next();          -      x      -     -
   close();         -      x      -     -
   update();        -      -      x     -
   insert();        x      -      -     -
   delete();        -      -      -     x

The framework can be extended to allow for column sorting,
aggregate functions, complex value expressions, complex
conditions, transactions, select caching, insert buffering,
etc.. The framework is not per se target towards proving
joins over tables. But it can be also enhanced in this
direction, even with distributed transactions.

Concerning joins, the participant XXXBeans need not come
from the same database. Deployment descriptions can define
the JDBC connection for individual XXXBeans. Here is how one
might copy from one table AAA column CCC to another table BBB
columnd DDD, where the two tables need not reside on the
same database.

   AAABean ab=new AAABean();
   ab.list();
   BBBBean bb=new BBBBean();
   while (ab.next()) {
     bb.calcDDD(ab.getCCC());
     bb.insert();
   }
   ab.close();

I am currently using such a framework called Matula. A very
old version which had ORM in mind is public (*). But now
its not classical ORM. Current drawback: Does not provide
delayed optimistic transactions as in Hybernate, since there
is no local object store.

Bye

(*)
http://www.xlog.ch/matula/

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


Thread

Apache JDBC utils markspace <-@.> - 2012-04-30 14:55 -0700
  Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-04-30 20:56 -0300
    Re: Apache JDBC utils markspace <-@.> - 2012-04-30 17:50 -0700
  Re: Apache JDBC utils Lew <lewbloch@gmail.com> - 2012-04-30 18:03 -0700
    Re: Apache JDBC utils markspace <-@.> - 2012-04-30 19:27 -0700
      Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-01 10:29 -0300
        Re: Apache JDBC utils markspace <-@.> - 2012-05-01 08:57 -0700
          Re: Apache JDBC utils Lew <lewbloch@gmail.com> - 2012-05-02 11:16 -0700
            Re: Apache JDBC utils markspace <-@.> - 2012-05-03 07:51 -0700
    Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-01 19:22 -0400
  Re: Apache JDBC utils Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-01 10:32 -0700
    Re: Apache JDBC utils markspace <-@.> - 2012-05-01 11:22 -0700
      Re: Apache JDBC utils Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-01 15:26 -0700
        Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-01 19:44 -0300
  Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-01 19:26 -0400
    Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-01 21:14 -0300
      Re: Apache JDBC utils Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-01 22:22 -0500
        Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 13:52 -0400
      Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 13:51 -0400
        Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-03 17:11 -0300
          Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 16:58 -0400
            Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-03 18:25 -0300
              Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 19:55 -0400
    Re: Apache JDBC utils Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-01 22:08 -0500
      Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 13:55 -0400
        Re: Apache JDBC utils Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-05-03 13:44 -0500
          Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 15:06 -0400
  Re: Apache JDBC utils "John B. Matthews" <nospam@nospam.invalid> - 2012-05-01 23:37 -0400
    Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-02 07:37 -0300
      Re: Apache JDBC utils "John B. Matthews" <nospam@nospam.invalid> - 2012-05-02 18:51 -0400
  Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-02 12:22 +0200
    Re: Apache JDBC utils markspace <-@.> - 2012-05-02 08:29 -0700
      Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-02 22:02 +0200
        Re: Apache JDBC utils Lew <lewbloch@gmail.com> - 2012-05-02 14:22 -0700
          Re: Apache JDBC utils Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-05-02 18:53 -0300
          Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 00:03 +0200
            Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 00:14 +0200
            Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 00:27 +0200
              Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 14:03 -0400
            Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-02 18:58 -0400
            Re: Apache JDBC utils Lew <lewbloch@gmail.com> - 2012-05-02 16:18 -0700
          Re: Apache JDBC utils Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-02 15:25 -0700
            Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 00:59 +0200
              Re: Apache JDBC utils Arne Vajhøj <arne@vajhoej.dk> - 2012-05-03 14:05 -0400
            Re: Apache JDBC utils Lew <lewbloch@gmail.com> - 2012-05-02 16:24 -0700
              Re: Apache JDBC utils Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-05-02 16:35 -0700
              Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 01:46 +0200
              Re: Apache JDBC utils Jan Burse <janburse@fastmail.fm> - 2012-05-03 01:49 +0200

csiph-web