From dev-return-6716-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Tue Nov 06 01:38:15 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 80695 invoked from network); 6 Nov 2007 01:38:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2007 01:38:15 -0000 Received: (qmail 70338 invoked by uid 500); 6 Nov 2007 01:38:03 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 70315 invoked by uid 500); 6 Nov 2007 01:38:03 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 70304 invoked by uid 99); 6 Nov 2007 01:38:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2007 17:38:03 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of plinskey@gmail.com designates 64.233.170.187 as permitted sender) Received: from [64.233.170.187] (HELO rn-out-0102.google.com) (64.233.170.187) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Nov 2007 01:38:06 +0000 Received: by rn-out-0102.google.com with SMTP id e13so664069rng for ; Mon, 05 Nov 2007 17:37:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=Y8KoatOArXpSvtJzeIf2JBJ/WwQUoRybRfnzb+0Q9r0=; b=H+MRioBVCkDCsckwZmTFyfHv4rfvxjIJHRLkoSKPRHYHtHFcwWTixt0eQEOFJklQUmSQ5vBsh6qXwIZ7WkUv0v2kvD1kZ78UXI3Pk2VFQudxIV4dAMiWxmHjXayrp15icRhuQ6b4ruHCa3rjcDjhDn126yW87Lk4F5cYIMkjBCQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EXucb9C+5ClIFngEOO4ErIGq03lpNwDWZe06Xk3gaZU1QqLmRCbIEDGIbOjxJX3v0eTqZHXpAjxrHyTW0WS+mJKqm65/AWQDUqwKg0ween3Kg4VulsY3hNtv+gYI4klM9zP7qGamSx8OW7wLIs9+5lR/YIgVG1ysx0t4jKwvf8E= Received: by 10.142.240.9 with SMTP id n9mr1363285wfh.1194313064073; Mon, 05 Nov 2007 17:37:44 -0800 (PST) Received: by 10.143.165.19 with HTTP; Mon, 5 Nov 2007 17:37:44 -0800 (PST) Message-ID: <7262f25e0711051737o1309dac2i47a0530136a0d530@mail.gmail.com> Date: Mon, 5 Nov 2007 17:37:44 -0800 From: "Patrick Linskey" To: dev@openjpa.apache.org, Marina.Vatkina@sun.com Subject: Re: Problem with @ManyToOne and @JoinTable In-Reply-To: <472FC2BB.9070305@Sun.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48D4843F-E9D6-46B2-B88D-E4B44D6D2CF3@pobox.com> <7262f25e0711050848o749e4ddck467146f65e2451c3@mail.gmail.com> <7262f25e0711050944h1b1a005anc2db31dcdbe61e48@mail.gmail.com> <562933F0-550E-4CA4-B1F3-542C8E4F984A@pobox.com> <7262f25e0711051107m3c91d369u69154fa5f1e3c617@mail.gmail.com> <2FEB3944-D951-4035-A92C-0E8B4BB13425@pobox.com> <7262f25e0711051205g2ee09c32m6cb687e5828692e4@mail.gmail.com> <472FC2BB.9070305@Sun.COM> X-Virus-Checked: Checked by ClamAV on apache.org I think he's actually trying to just have a single (unidirectional) reference -- I think he added the backpointer just to see if he could get things working that way. -Patrick On Nov 5, 2007 5:26 PM, Marina Vatkina wrote: > You need to have @OneToMany(mappedBy="show") - otherwise you get 2 > unidirectional relationships, while you are trying to make them bidirectional. > > Regards, > -marina > > > Geir Magnusson Jr. wrote: > > To review, I have three tables : > > > > Show, InputFile and a join table, Show2InputFile. > > > > Show happens to be a subclass of InventoryItem using JOINED inheritance > > strategy. Not sure if that matters. (I've seen some weird behavior w/ > > Hibernate w/ JOINED, so I'm suspicious of it for no rational reason) > > > > Show has a PK "id", as does InputFile. > > > > Show2InputFile looks like : > > > > +-------------+------------------+------+-----+---------+-------+ > > | Field | Type | Null | Key | Default | Extra | > > +-------------+------------------+------+-----+---------+-------+ > > | showId | int(11) unsigned | NO | PRI | | | > > | inputFileId | int(11) unsigned | NO | PRI | | | > > +-------------+------------------+------+-----+---------+-------+ > > > > I believe it's unidirectional ManyToOne (if that's legal). Each > > InputFile is associated with one Show and one Show only, but multiple > > InputFiles can be associated to the same Show. > > > > Currently I have in InputFile : > > > > @ManyToOne > > @JoinTable(name="Show2InputFile", > > joinColumns = @JoinColumn(name="inputFileId"), > > inverseJoinColumns = @JoinColumn(name="showId")) > > public Show getShow() { > > return show; > > } > > > > and while Hibernate thinks that's just peachy, OpenJPA 1.0.0 gags on it > > with > > > > Caused by: > > org.apache.openjpa.persistence.ArgumentException: You have supplied > > columns for "com.joost.model.logistics.InputFile.show > java.lang.Object>", but this mapping cannot have columns in this context. > > > > Now, while I don't want to add anything to the Show class, since this > > really is unidirectional, I did add : > > > > @OneToMany > > @JoinTable(name="Show2InputFile", > > inverseJoinColumns = @JoinColumn(name="inputFileId"), > > joinColumns = @JoinColumn(name="showId")) > > public Set getInputFiles(){ > > return null; > > } > > > > public void setInputFiles(Set list) { > > //noop > > } > > > > just to see if that would make OpenJPA happy, but as far as I can see, > > it doesn't. I believe I get the same error message. > > > > I really want to switch to OpenJPA, but this is stopping me. Does > > anyone have any idea what I'm doing wrong? > > > > geir > > > > > > On Nov 5, 2007, at 3:05 PM, Patrick Linskey wrote: > > > >> Where are the foreign keys? > >> > >> Bear in mind that @OneToOne, @OneToMany, @ManyToMany, and @ManyToOne > >> are JPA annotations, not ER annotations. The concepts differ a bit. > >> > >> -Patrick > >> > >> On Nov 5, 2007 11:33 AM, Geir Magnusson Jr. wrote: > >> > >>> > >>> On Nov 5, 2007, at 2:07 PM, Patrick Linskey wrote: > >>> > >>>>>> What happens if you just use a @OneToOne instead of the @ManyToOne? > >>>>> > >>>>> > >>>>> The problem is that it's not OneToOne > >>>> > >>>> > >>>> Can you describe this in more detail? (I.e., in terms of what your > >>>> schema looks like.) > >>>> > >>> > >>> Well, there's a Show table, w/ a pk, and the Show class really has no > >>> interest in the InputFile class. > >>> > >>> There's an inputfile table, w/ a pk. The InputFile class does have a > >>> ManyToOne with Show : > >>> > >>> In real world problem, each Show we have on the platform is a > >>> singleton ("I dream of Genie Epsode 11"), but a content owner may > >>> give us updated source material - say they have a new transcoding. > >>> We want to add a new InputFile into the database, point it at the > >>> Show, but the Show itself doesn't care about it's source. > >>> > >>> Does that help? > >>> > >>> eir > >>> > >>> > >>> > >>>> -Patrick > >>>> > >>>> On Nov 5, 2007 10:40 AM, Geir Magnusson Jr. wrote: > >>>> > >>>>> > >>>>> On Nov 5, 2007, at 12:44 PM, Patrick Linskey wrote: > >>>>> > >>>>>>> I'm a newbie, so I don't quite grok the question. Show itself > >>>>>>> doesn't have any references to InputFile. > >>>>>> > >>>>>> > >>>>>> Aha! IIRC, @ManyToOne is only meaningful when used as the back > >>>>>> side of > >>>>>> a @OneToMany. > >>>>> > >>>>> > >>>>> We don't have that. There are reasons, and its intentional. > >>>>> > >>>>>> > >>>>>> What happens if you just use a @OneToOne instead of the @ManyToOne? > >>>>> > >>>>> > >>>>> The problem is that it's not OneToOne > >>>>> > >>>>> > >>>>>> > >>>>>> -Patrick > >>>>>> > >>>>>> On Nov 5, 2007 9:16 AM, Geir Magnusson Jr. wrote: > >>>>>> > >>>>>>> > >>>>>>> On Nov 5, 2007, at 11:48 AM, Patrick Linskey wrote: > >>>>>>> > >>>>>>>> Hi, > >>>>>>>> > >>>>>>>> What does the other side of the relation look like? > >>>>>>> > >>>>>>> > >>>>>>> I'm a newbie, so I don't quite grok the question. Show itself > >>>>>>> doesn't have any references to InputFile. > >>>>>>> > >>>>>>>> Also, what does > >>>>>>>> the Show class look like? > >>>>>>> > >>>>>>> > >>>>>>> in what way? Show is a subclass in a JOINED inheritance > >>>>>>> strategy, if > >>>>>>> that makes any difference. > >>>>>>> > >>>>>>> geir > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>>> > >>>>>>>> -Patrick > >>>>>>>> > >>>>>>>> On Nov 5, 2007 8:08 AM, Geir Magnusson Jr. wrote: > >>>>>>>> > >>>>>>>>> I'm a newbie, so forgive me if I'm not asking the question the > >>>>>>>>> right > >>>>>>>>> way. > >>>>>>>>> > >>>>>>>>> I have a join table in my DB : > >>>>>>>>> > >>>>>>>>> +-------------+------------------+------+-----+--------- +-------+ > >>>>>>>>> | Field | Type | Null | Key | Default | Extra | > >>>>>>>>> +-------------+------------------+------+-----+--------- +-------+ > >>>>>>>>> | showId | int(11) unsigned | NO | PRI | | | > >>>>>>>>> | inputFileId | int(11) unsigned | NO | PRI | | | > >>>>>>>>> +-------------+------------------+------+-----+--------- +-------+ > >>>>>>>>> > >>>>>>>>> where showId and inputFileID are PKs in the show table and > >>>>>>>>> inputfile > >>>>>>>>> table. > >>>>>>>>> > >>>>>>>>> In my code for the InputFile class : > >>>>>>>>> > >>>>>>>>> @ManyToOne > >>>>>>>>> @JoinTable(name="Show2InputFile", > >>>>>>>>> joinColumns = @JoinColumn(name="inputFileId"), > >>>>>>>>> inverseJoinColumns = @JoinColumn(name="showId")) > >>>>>>>>> public Show getShow() { > >>>>>>>>> return show; > >>>>>>>>> } > >>>>>>>>> > >>>>>>>>> When JPA is instrumenting my classes, it complains : > >>>>>>>>> > >>>>>>>>> Caused by: >>>>>>>>> error> > >>>>>>>>> org.apache.openjpa.persistence.ArgumentException: You have > >>>>>>>>> supplied > >>>>>>>>> columns for > >>>>>>>>> "com.joost.model.logistics.InputFile.show >>>>>>>>> java.lang.Object>", but this mapping cannot have columns in this > >>>>>>>>> context. > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> I don't quite understand the error. I use this same thing > >>>>>>>>> elsewhere > >>>>>>>>> (I think) w/o a problem. Can someone give me a hint? > >>>>>>>>> > >>>>>>>>> geir > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> -- > >>>>>>>> Patrick Linskey > >>>>>>>> 202 669 5907 > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> -- > >>>>>> Patrick Linskey > >>>>>> 202 669 5907 > >>>>> > >>>>> > >>>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> Patrick Linskey > >>>> 202 669 5907 > >>> > >>> > >>> > >> > >> > >> > >> -- > >> Patrick Linskey > >> 202 669 5907 > > > > > -- Patrick Linskey 202 669 5907