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


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

Re: From JDBC to JPA

From Fredrik Jonson <fredrik@jonson.org>
Newsgroups comp.lang.java.programmer
Subject Re: From JDBC to JPA
Date 2015-07-25 08:12 +0000
Message-ID <slrnmr6h6k.7mm.fredrik@biggles.jonson.org> (permalink)
References <87380doatw.fsf@Equus.decebal.nl> <motqel$lmt$1@dont-email.me> <87y4i5mig2.fsf@Equus.decebal.nl>

Show all headers | View raw


In <87y4i5mig2.fsf@Equus.decebal.nl> Cecil Westerhof wrote:

>  I need to write clean JPA code, because it should be possible two switch
>  from Hibernate to openJPA in a moments notice.

That is a requirement that is not as easy to fulfill as is appears on first
sight. Especially for someone who does not have experience with JPA already.

I think you'll find that each JPA implementation has its own set of quirks in
performance as well as in configuration. And since you're combining it with a
database, you'll have your database provider's quirks to consider too.

A more reasonable goal is to use only standard JPA annotations for the beans
and most queries, and otherwise aim to limit the provider specific stuff to
parts of the code that you design to be rather easily replaceable when you
decide to try to migrate to another provider. That said, you can get quite far
with plain JPA, at least as long as your database model isn't too complex.

Not to say that JPA is special in this way. Almost every standard that have
multiple implementations also have quirks that are specific to each
implementation. The common case is obviously usually better covered and more
similar between implementations.

On a related theme: Do not be afraid to use native queries when building more
complex queries. There's nothing wrong with JQL, but you do not have the same
control over the details compared to plain SQL.

-- 
Fredrik Jonson

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


Thread

From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 17:05 +0200
  Re: From JDBC to JPA Eternal Hope <laughingspam99@gmail.com> - 2015-07-24 17:53 +0100
    Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 22:03 +0200
      Re: From JDBC to JPA Eternal Hope <laughingspam99@gmail.com> - 2015-07-25 05:23 +0100
        Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-25 10:37 +0200
          Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:45 -0400
      Re: From JDBC to JPA Fredrik Jonson <fredrik@jonson.org> - 2015-07-25 08:12 +0000
        Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:49 -0400
      Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:38 -0400
  Re: From JDBC to JPA Joerg Meier <joergmmeier@arcor.de> - 2015-07-24 20:40 +0200
  Re: From JDBC to JPA Jeff Higgins <jeff@invalid.invalid> - 2015-07-24 15:45 -0400
    Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 22:32 +0200
  Re: From JDBC to JPA Joerg Meier <joergmmeier@arcor.de> - 2015-07-24 22:32 +0200
    Re: From JDBC to JPA Cecil Westerhof <Cecil@decebal.nl> - 2015-07-24 23:18 +0200
  Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 14:40 -0400
    Re: From JDBC to JPA Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 23:53 -0400
      Re: From JDBC to JPA Lew <lewbloch@gmail.com> - 2015-08-03 15:43 -0700

csiph-web