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


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

Re: Hibernate foreign key as primary key

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Hibernate foreign key as primary key
Date Wed, 10 Aug 2011 09:58:03 -0700 (PDT)
Organization http://groups.google.com
Lines 58
Message-ID <70240bbb-ec23-4d96-89c1-260337f0df8b@glegroupsg2000goo.googlegroups.com> (permalink)
References <4e3e78a1@dnews.tpgi.com.au> <9a7tq6FspmU1@mid.individual.net> <9a7vglFa7hU1@mid.individual.net> <4e3fb5d8@dnews.tpgi.com.au>
Reply-To comp.lang.java.programmer@googlegroups.com
NNTP-Posting-Host 2620:0:1000:fd42:224:d7ff:fe69:5838
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1312995484 21182 127.0.0.1 (10 Aug 2011 16:58:04 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Wed, 10 Aug 2011 16:58:04 +0000 (UTC)
In-Reply-To <4e3fb5d8@dnews.tpgi.com.au>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:fd42:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6982

Show key headers only | View raw


On Monday, August 8, 2011 3:11:52 AM UTC-7, Lionel wrote:
> On 08/08/11 03:14, Robert Klemme wrote:
> > On 07.08.2011 18:45, Frank Langelage wrote:
> >> On 07.08.11 13:38, Lionel wrote:
> >>> This may be a little off topic but I'm sure there are some experts in
> >>> here.
> >>>
> >>> I'm having some troubles getting using a foreign key as a primary key.
> >>> In this post I will use the most simple issue I'm having trouble with.
> >>>
> >>> Here's some snippets (pharmacy project):
> >>>
> >>> public abstract class AbstractDrugModel
> >>> {
> >>> private String name;
> >>> private IntravascularDrug ivDrug;
> >>> }
> >>>
> >>> public class IntravascularDrug
> >>> {
> >>> private AbstractDrugModel drug;
> >>> }
> >>
> >> I can't help you with your problem but want to give a comment to this
> >> mail.
> >> Your class design does not make sense to me. You have a circular
> >> reference between these two classes. Java allows this, but this is bad
> >> design in my eyes.
> >
> > ... but very common for bidirectional relationships. If instances of
> > both classes need to be able to navigate the relationship that design is
> > the most efficient solution.
> 
> Yes. This is normal design. But read one.
> 
> 
> >> And this might be the cause that hibernate cannot work with this design.
> >
> > Yes, might be.
> 
> My original relationship was actually unidirectional, there was no need 
> for the IntravascularDrug to know about the AbstractDrugModel. However, 
> to map the relationship in Hibernate somehow Hibernate needs to be able 
> to get the primary key for IntravascularDrug which happens to be the 
> primary key of AbstractDrugModel and is hence also a foreign key of 
> IntravascularDrug.
> 
> I thought there might be more knowledge of hibernate [sic] on this forum, but 
> based on the responses it seems it is too specific for this forum. I 
> just wasn't getting responses to other questions on the Hibernate forum 
> (and neither were many other people though there are a high number of 
> posts) so I decided to try on my preferred medium :).

The annotative version (JPA-compliant) would be easier to follow.

-- 
Lew

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


Thread

Hibernate foreign key as primary key Lionel <lionelv@none.com> - 2011-08-07 21:38 +1000
  Re: Hibernate foreign key as primary key markspace <-@.> - 2011-08-07 07:07 -0700
  Re: Hibernate foreign key as primary key Robert Klemme <shortcutter@googlemail.com> - 2011-08-07 18:03 +0200
  Re: Hibernate foreign key as primary key Frank Langelage <frank@lafr.de> - 2011-08-07 18:45 +0200
    Re: Hibernate foreign key as primary key Robert Klemme <shortcutter@googlemail.com> - 2011-08-07 19:14 +0200
      Re: Hibernate foreign key as primary key Lionel <lionelv@none.com> - 2011-08-08 20:11 +1000
        Re: Hibernate foreign key as primary key Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-08 18:26 -0300
          Re: Hibernate foreign key as primary key Lionel <lionelv@none.com> - 2011-08-09 18:56 +1000
            Re: Hibernate foreign key as primary key Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-08-09 21:45 -0300
        Re: Hibernate foreign key as primary key Lew <lewbloch@gmail.com> - 2011-08-10 09:58 -0700

csiph-web