From: | Lew <noone(at)lewscanon(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: JPA and desktop apps |
Date: | 2010-07-23 12:48:18 |
Message-ID: | i2c31v$elh$1@news.albasani.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Craig Ringer wrote:
> Ages ago, I asked here if others were using JDBC directly to access Pg
> from their java apps, or if they were using an ORM. I sought advice.
> Many suggested that an ORM was a strongly preferable option, and partly
> as a result of that advice I ended up using the JPA interface (with
> Hibernate powering it) for my database access in my Swing app.
>
> I've now concluded that, while it seems great on the surface, that
> approach is absolutely awful, because of issues with detatched entities,
> lazy property fetching, and the need to run database work on a non-EDT
> thread to avoid UI stalls/freezes and repaint delays.
I don't find JPA a problem at all - it's a huge boost. Naturally you have to
deal with properly setting it up, just like anything else.
If lazy fetching is bad for you, use eager fetching. Simple.
You need to run DB work on a non-GUI thread if you don't use an ORM. How is
that different?
Detached entities are part of a solution, not part of a problem.
> Anyway, since folks here advised me to go for an ORM like Hibernate, I'm
> curious: How do you handle the need to avoid blocking on database access
> in your Java GUI apps, while lazily fetching properties of entities to
> avoid downloading half the database whenever you query it for anything?
Proper design of entities to fit with a proper object model.
Proper separation of view from model, just like if you don't use an ORM.
Methinks you blame the hammer for the carpenter.
--
Lew
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2010-07-23 13:23:55 | Re: [HACKERS] Trouble with COPY IN |
Previous Message | Matthew Wakeling | 2010-07-23 09:33:27 | Re: Trouble with COPY IN |