Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Frank Langelage Newsgroups: comp.lang.java.programmer Subject: Re: Hibernate foreign key as primary key Date: Sun, 07 Aug 2011 18:45:57 +0200 Lines: 24 Message-ID: <9a7tq6FspmU1@mid.individual.net> References: <4e3e78a1@dnews.tpgi.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net a4gn8Ff24IGW9duCX3AVuAtptDIYGXKE0bT5XWtBaOBdB17K0= Cancel-Lock: sha1:ydEcRyIH8MpVVSAFOZ+I9BirLJ0= User-Agent: Mozilla/5.0 (X11; SunOS sun4u; rv:5.0) Gecko/20110629 Thunderbird/5.0 In-Reply-To: <4e3e78a1@dnews.tpgi.com.au> Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6855 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. And this might be the cause that hibernate cannot work with this design.