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


Groups > comp.lang.java.databases > #645

Re: Local database library

Date 2013-10-26 18:39 -0400
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.databases
Subject Re: Local database library
References (2 earlier) <20131004110242.1be4f5ea@efreet.linux> <d50f8d5a-bf95-4d95-bc93-6a53b0a16522@googlegroups.com> <20131005120659.39a89f3b@efreet.linux> <ec4d1b88-d33a-4b76-a0e6-709319845718@googlegroups.com> <20131026120811.1a9bc341@efreet.linux>
Message-ID <526c448a$0$302$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


On 10/26/2013 3:08 PM, Kevin Nathan wrote:
> On Tue, 15 Oct 2013 16:41:16 -0700 (PDT)
> Lew <lewbloch@gmail.com> wrote:
>>> and even more complex queries into JPA, I will start that process.
>>
>> That would be insane and stupid.
>>
>> You don't convert queries into JPA; that's utterly backwards. If you
>> have a data orientation, you use straight-up JDBC, not JPA.
>>
>> JPA is for creating persistent *objects*.
>>
>
> I have mentioned in this thread that I am *very* new to Java. But I've
> been programming since 1979 (very little formal training). I mentioned
> JPA because you said that was by far the easiest to code and maintain.
> I know nothing about it.

It often is.

But not always.

> It's not SQL that is the brute force method, it's putting the SQL into
> every Java file that needs it, often the same query, or very similar,
> query. It works, but not what I would like to see. The data access is
> not split out from the rest of the code, and that was what I was
> wanting to do.
>
>> Your queries, if they are reasonably standard SQL, go directly into
>> JDBC 'Statement' objects. (Use 'PreparedStatement'.)
>
> That's what we use. But the previous programmers simply stuck them in
> every class (copy/paste), as needed, so the SQL is scattered throughout
> the code. In the C++ code we have a locally written DAO library of
> various classes like Transaction, Seller, Buyer, etc., and if you need
> a list of Transactions by Seller, you simply include those classes and
> call methods. So, I was hoping to make a simple mirror of our C++ DAO
> library. I can't make it work. I don't know what I am missing (very new
> to Java, remember).

You need to distinguish between:
- DAO classes vs no DAO classes
- SQL in many classes vs SQL in one class

Regarding the last question, then I will suggest
having the SQL near the code using the SQL. That
is where it belongs.

 > And I obviously cannot explain my problem well enough, so I will not
 > bother you with this anymore. Maybe, if I knew Java better, I could
 > formulate a better question or series of questions. For now, I will
 > just continue putting the raw SQL into every class and later, when I
 > know what I am doing in Java, I will clean it up.

I think you should post more questions - maybe with some small
examples.

Arne

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


Thread

Local database library Kevin Nathan <knathan@project54.com> - 2013-10-01 13:52 -0700
  Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-01 17:38 -0400
    Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-01 15:41 -0700
      Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-01 20:53 -0400
        Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-02 10:09 -0700
          Re: Local database library Martin Gregorie <martin@address-in-sig.invalid> - 2013-10-02 19:49 +0000
            Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-04 10:48 -0700
              Re: Local database library Martin Gregorie <martin@address-in-sig.invalid> - 2013-10-05 15:43 +0000
                Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-05 11:19 -0700
          Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-02 22:05 -0400
            Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-04 10:57 -0700
              Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-04 22:00 -0400
                Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-05 11:28 -0700
                Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-05 15:15 -0400
                Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-05 12:49 -0700
  Re: Local database library "John B. Matthews" <nospam@nospam.invalid> - 2013-10-02 15:37 -0400
    Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-04 11:02 -0700
      Re: Local database library Lew <lewbloch@gmail.com> - 2013-10-04 15:56 -0700
        Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-05 12:06 -0700
          Re: Local database library Lew <lewbloch@gmail.com> - 2013-10-15 16:41 -0700
            Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-26 12:08 -0700
              Re: Local database library Martin Gregorie <martin@address-in-sig.invalid> - 2013-10-26 21:04 +0000
                Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-26 18:58 -0700
              Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-26 18:39 -0400
                Re: Local database library Kevin Nathan <knathan@project54.com> - 2013-10-26 19:04 -0700
            Re: Local database library Arne Vajhøj <arne@vajhoej.dk> - 2013-10-26 18:33 -0400

csiph-web