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


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

Re: Persistence API - magic?

From Arved Sandstrom <asandstrom3minus1@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Persistence API - magic?
References <7e3a3be9-8960-4b94-8028-2da962435fc8@u6g2000yqa.googlegroups.com> <j46ev4$fpo$1@dont-email.me>
Message-ID <jCG9q.7679$CQ4.3453@newsfe09.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2011-09-07 06:14 -0300

Show all headers | View raw


On 11-09-06 09:47 PM, markspace wrote:
> On 9/6/2011 3:52 PM, nroberts wrote:
> 
>> One tutorial on persistence that I found (
>> http://www.javaworld.com/javaworld/jw-01-2008/jw-01-jpa1.html?page=3 )
>> explains how to make them by hand but it uses an orm.xml or
>> annotations to tell Java what table and what columns to connect an
>> entity object with.  The eclipse stuff doesn't seem to do that at
>> all.  The orm.xml file exists, but it's practically empty containing
>> nothing but the root element and xml tag.
> 
> I'm actually working on learning some JPA/JSF stuff right now too.  The
> orm.xml stuff confuses me because I haven't seen it before.  I'm used to
> a persistence.xml file being used.  I'm concerned about versions here
> and portability, because you seem to be configuring the tool directly,
> and not using the JPA config file.
> 
> Does anyone know what this config file is about?  What version of the
> library uses it?  It either seems specific to his library, and therefore
> non-portable, or it's really old.

It's portable and it's JPA. orm.xml is the object-relational mapping
file for JPA; it's been around from the gitgo and is still very much in
play. You can define your mappings using annotations in entity classes,
or using orm.xml, or both.

As I suggested to the OP earlier, at the moment he can leave his
vestigial Eclipse-generated orm.xml alone, and stick to annotations
only. I'm not discouraging the use of orm.xml at all, but at the
learning stage it can be ignored.

>> I was thinking that perhaps it was order based, but the order of the
>> columns in the zip table to do not match.
> 
> It's based on name, afaik.  The entity manager will strip off the "get"
> or "set" of your accessors/mutators, or it will use the field name, and
> look up a column of the same name.   Sometimes case doesn't matter (may
> depend on your database, i.e., it could be non-portable to rely on case
> insensitivity).  There's also ways of mapping from one column to an
> object property if the names are different.
[ SNIP ]

It's all based on names, we've got nothing else in play. :-)

As I mentioned to the OP previously, this is all defined in the
specifications _and_ in the Javadocs. For example, if @ManyToOne is
under consideration, and @JoinColumn is defaulted, the name of the
referenced table is inferred from the type(name) of object being
referenced. And all other defaults of @JoinColumn kick in.

AHS

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


Thread

Persistence API - magic? nroberts <roberts.noah@gmail.com> - 2011-09-06 15:52 -0700
  Re: Persistence API - magic? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-06 21:40 -0300
    Re: Persistence API - magic? nroberts <roberts.noah@gmail.com> - 2011-09-07 07:56 -0700
      Re: Persistence API - magic? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-07 17:34 -0300
  Re: Persistence API - magic? markspace <-@.> - 2011-09-06 17:47 -0700
    Re: Persistence API - magic? Lew <lewbloch@gmail.com> - 2011-09-06 18:26 -0700
      Re: Persistence API - magic? markspace <-@.> - 2011-09-06 19:01 -0700
    Re: Persistence API - magic? Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-09-07 06:14 -0300
    Re: Persistence API - magic? nroberts <roberts.noah@gmail.com> - 2011-09-07 08:10 -0700
      Re: Persistence API - magic? markspace <-@.> - 2011-09-07 09:15 -0700
        Re: Persistence API - magic? Lew <lewbloch@gmail.com> - 2011-09-07 10:36 -0700
          Re: Persistence API - magic? markspace <-@.> - 2011-09-07 10:57 -0700
            Re: Persistence API - magic? Lew <lewbloch@gmail.com> - 2011-09-07 11:06 -0700
  Re: Persistence API - magic? Lew <lewbloch@gmail.com> - 2011-09-06 18:09 -0700
  Re: Persistence API - magic? Roedy Green <see_website@mindprod.com.invalid> - 2011-09-08 12:32 -0700
    Re: Persistence API - magic? "John B. Matthews" <nospam@nospam.invalid> - 2011-09-08 19:23 -0400

csiph-web