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


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

Re: Persistence API - magic?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Persistence API - magic?
Date Tue, 06 Sep 2011 19:01:52 -0700
Organization A noiseless patient Spider
Lines 39
Message-ID <j46jb5$5cd$1@dont-email.me> (permalink)
References <7e3a3be9-8960-4b94-8028-2da962435fc8@u6g2000yqa.googlegroups.com> <j46ev4$fpo$1@dont-email.me> <14a59736-46ca-4642-bbbc-88b59a3ed401@glegroupsg2000goo.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 7 Sep 2011 02:02:13 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="5517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/k7q+4FMnOUqVib8UL46cy+vxHO9jk/Lk="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1
In-Reply-To <14a59736-46ca-4642-bbbc-88b59a3ed401@glegroupsg2000goo.googlegroups.com>
Cancel-Lock sha1:Tgh6kQQxMK8iGSf9OH/3O4lOWjE=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7659

Show key headers only | View raw


On 9/6/2011 6:26 PM, Lew wrote:
> I'm pretty sure it's a Hibernatism, supplanted by persistence.xml for
> all practical purposes.


Thanks for pointing that out!


> 'Country country;' with an '@ManyToOne'.  NOT A COLUMN!  It is an
> OBJECT RELATIONSHIP, NOT A COLUMN!


Oops, I didn't read his example carefully, and I missed that.

So what's going on there is that Country is an entity too:

@Entity
public class Country {
   @Id
   int id;
   String name; // ?  other properties...
...
}

And JPA will automatically put a foreign key in the table "Zip" that 
relates to the primary key in the table "Country" (I'm using class names 
here because you didn't specify differently, e.g. using 
@Table(name="A_TABLE_NAME")) and then JPA will do the join for you.

However, watch out for lazy loading and detachment.


> You specify the column inside the '@ManyToOne' annotation, not as a
> field in the 'MyClass' (terrible name for an entity!).


Yeah the "MyClass" was just to make it abundantly clear that my example 
wasn't related to the code posted by N. Roberts.

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