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


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

Re: JPA: annotations or XML?

Date 2013-12-24 23:11 -0500
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.databases
Subject Re: JPA: annotations or XML?
References <l8nov9$sq4$1@speranza.aioe.org>
Message-ID <52ba5ad5$0$296$14726298@news.sunsite.dk> (permalink)
Organization SunSITE.dk - Supporting Open source

Show all headers | View raw


On 12/16/2013 3:48 PM, Ricardo Palomaes wrote:
> I've always been against libraries using declarative XML files since I
> felt that it added burden and an additional hurdle to use them besides
> coding. As result of it, I initially liked very much annotations over
> XML files in JPA.

But the XML config files centralized the mapping, which could certainly
be seen as an advantage.

But JPA went the route it did.

> However, I'd like to design the application in such a way that it
> could use a local database persistence (now) or one based in
> webservices (as a future enhancement). I'm still learning, but it
> seems that I should use a DAO pattern. This is not a requirement, but
> a "nice to have".

Yes - a DAL.

> I have two questions:
>
> 1) (This may be really naive) I've read that JPA acts in some way as a
> DAO layer but, will the JPA architecture keep track of entity object
> passing through a "real" DAO layer, used in a context unaware of JPA
> (the application GUI classes, for instance) and later returned again
> to the JPA through the DAO without too much hassle?

What do you mean by "keep track of"?

> 2) Would I be able, by using XML files instead of annotations in JPA,
> to keep my POJOs completely clean,

I believe you can. JPA supports XML files as well as annotations. But I
have never seen XML files used. It will cost you in training of people
for long term maintenance relying on such a rare feature.

>                                so I could use them in both JPA and
> webservice persistence providers in a DAO architecture, with the web
> service part not having to include any package from JPA?

Having JPA annotation on classes used outside DAL is a bit ugly.

An alternative approach is to have both real data classes and DTO
classes. But that duplicate some code.

All pros and cons ...........

Arne

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


Thread

JPA: annotations or XML? Ricardo Palomaes <rpmdisguise-java@nowhere.com> - 2013-12-16 21:48 +0100
  Re: JPA: annotations or XML? Arne Vajhøj <arne@vajhoej.dk> - 2013-12-24 23:11 -0500
    Re: JPA: annotations or XML? Stanimir Stamenkov <s7an10@netscape.net> - 2013-12-25 13:21 +0200
      Re: JPA: annotations or XML? Arne Vajhøj <arne@vajhoej.dk> - 2013-12-27 22:34 -0500
        Re: JPA: annotations or XML? Stanimir Stamenkov <s7an10@netscape.net> - 2014-01-02 11:31 +0200

csiph-web