Re: JPA and desktop apps

Поиск
Список
Период
Сортировка
От Lew
Тема Re: JPA and desktop apps
Дата
Msg-id i2c31v$elh$1@news.albasani.net
обсуждение исходный текст
Ответ на JPA and desktop apps  (Craig Ringer <craig@postnewspapers.com.au>)
Ответы Re: JPA and desktop apps
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Matthew Wakeling
Дата:
Сообщение: Re: Trouble with COPY IN
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: [HACKERS] Trouble with COPY IN