Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 63905 invoked from network); 19 Apr 2007 18:13:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2007 18:13:15 -0000 Received: (qmail 75828 invoked by uid 500); 19 Apr 2007 18:13:17 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 75798 invoked by uid 500); 19 Apr 2007 18:13:17 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 75713 invoked by uid 99); 19 Apr 2007 18:13:16 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2007 11:13:16 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [66.45.238.226] (HELO server1.splicexeon1.com) (66.45.238.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2007 11:13:08 -0700 Received: from [63.170.55.63] (port=34480 helo=[172.16.47.167]) by server1.splicexeon1.com with esmtpa (Exim 4.63) (envelope-from ) id 1Heb7X-0003w6-TU for open-jpa-dev@incubator.apache.org; Thu, 19 Apr 2007 14:12:41 -0400 Message-ID: <4627B196.4010003@joyfulnoisewebdesign.com> Date: Thu, 19 Apr 2007 13:14:46 -0500 From: "Jay D. McHugh" User-Agent: Thunderbird 1.5 (X11/20060204) MIME-Version: 1.0 To: open-jpa-dev@incubator.apache.org Subject: Re: One to many relationship problem References: <4627AB68.5060605@joyfulnoisewebdesign.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server1.splicexeon1.com X-AntiAbuse: Original Domain - incubator.apache.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - joyfulnoisewebdesign.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Checked: Checked by ClamAV on apache.org Marc, Here is the code block: System.out.println("About to do a 'getAttributes' call..."); componentClass.getAttributes(); System.out.println("Finished the 'getAttributes' call..."); And here is the trace: 40217 palmJPA TRACE [http-0.0.0.0-8080-4] openjpa.jdbc.SQL - executing prepstmnt 566738 SELECT t0.classDeprecated, t0.classDescription FROM class t0 WHERE t0.classID = ? [params=(long) 1] 40218 palmJPA TRACE [http-0.0.0.0-8080-4] openjpa.jdbc.SQL - [1 ms] spent 40218 palmJPA TRACE [http-0.0.0.0-8080-4] openjpa.jdbc.JDBC - [0 ms] close About to do a 'getAttributes' call... Finished the 'getAttributes' call... Nothing happened at all in between the two System.out.println's - is there a more verbose level of logging than TRACE? Jay Marc Prud'hommeaux wrote: > Jay- > > Nothing jumps out at me as being wrong with your mapping... > >> Note: I don't get any errors or exceptions, just no secondary queries >> when I do a 'find(' > > If you call ComponentClass.getAttributes(), are you saying that no SQL > is executed? That would be surprising. Can you enable SQL logging and > sent the resulting SQL from some code like: > > ComponentClass c = em.find(ComponentClass.class, someExistingId); > c.getAttributes(); > > > > > On Apr 19, 2007, at 10:48 AM, Jay D. McHugh wrote: > >> Hello all, >> >> I am trying to map a one to many relationship with the 'one' side as >> the relationship owner using @EntityJoinColumn. >> >> Actually, I am trying to do this several times within my persistence >> unit. >> >> In two cases, it seems to be working - but no matter what I do >> (including giving up on having the 'one' side own the relationship >> and push it over to the 'many' side) I cannot seem to get a third >> case to work. It just refuses to acknowledge that there is any >> reference that needs to be followed. >> >> Here are the two classes that are supposed to be linked - Can anyone >> see a problem with how I did this? >> >> Note: I don't get any errors or exceptions, just no secondary queries >> when I do a 'find(' >> >> Thanks for any help, >> >> Jay >> >> ----------- Class 1 ------------- >> package com.pubint.ejb.entity; >> >> import java.util.ArrayList; >> import java.util.Collection; >> import java.util.Iterator; >> >> import javax.persistence.Column; >> import javax.persistence.Entity; >> import javax.persistence.GeneratedValue; >> import javax.persistence.GenerationType; >> import javax.persistence.Id; >> import javax.persistence.OneToMany; >> import javax.persistence.Table; >> >> import org.apache.openjpa.persistence.jdbc.ElementJoinColumn; >> >> @Entity >> @Table(name="componentClass") >> public class ComponentClass { >> private long classID; >> private String classDescription; >> private boolean classDeprecated; >> >> private Collection attributes = new >> ArrayList(); >> >> public ComponentClass() { >> >> } >> >> @Id >> @GeneratedValue(strategy = GenerationType.IDENTITY) >> @Column(name="classID") >> public long getClassID() { >> return classID; >> } >> >> public void setClassID(long classID) { >> this.classID = classID; >> } >> >> @Column(name="classDescription") >> public String getClassDescription() { >> return classDescription; >> } >> >> public void setClassDescription(String classDescription) { >> this.classDescription = classDescription; >> } >> >> @Column(name="classDeprecated") >> public boolean isClassDeprecated() { >> return classDeprecated; >> } >> >> public void setClassDeprecated(boolean classDeprecated) { >> this.classDeprecated = classDeprecated; >> } >> >> @OneToMany >> @ElementJoinColumn(name="classID", referencedColumnName="classID") >> public Collection getAttributes() { >> return attributes; >> } >> >> public void addAttribute(ClassAttrib attribute) { >> attributes.add(attribute); >> } >> } >> >> >> -------------- Class 2 -------------------- >> package com.pubint.ejb.entity; >> >> import javax.persistence.Column; >> import javax.persistence.Entity; >> import javax.persistence.GeneratedValue; >> import javax.persistence.GenerationType; >> import javax.persistence.Id; >> import javax.persistence.JoinColumn; >> import javax.persistence.ManyToOne; >> import javax.persistence.Table; >> >> @Entity >> @Table(name="xClassAttrib") >> public class ClassAttrib { >> private long id; >> private long classID; >> private Attrib attribute; >> private long displaySequence; >> private boolean mandatory; >> private boolean requiresPrototype; >> private boolean lockedByPrototype; >> >> public ClassAttrib() { >> >> } >> >> @Id >> @GeneratedValue(strategy = GenerationType.IDENTITY) >> @Column(name="id") >> public long getId() { >> return id; >> } >> >> public void setId(long id) { >> this.id = id; >> } >> public long getClassID() { >> return classID; >> } >> public void setClassID(long classID) { >> this.classID = classID; >> } >> >> @ManyToOne >> @JoinColumn(name="attributeID") >> public Attrib getAttribute() { >> return attribute; >> } >> >> public void setAttribute(Attrib attribute) { >> this.attribute = attribute; >> } >> >> @Column(name="displaySequence") >> public long getDisplaySequence() { >> return displaySequence; >> } >> >> public void setDisplaySequence(long seq) { >> displaySequence = seq; >> } >> >> @Column(name="mandatory") >> public boolean isMandatory() { >> return mandatory; >> } >> >> public void setMandatory(boolean mandatory) { >> this.mandatory = mandatory; >> } >> >> @Column(name="lockedByPrototype") >> public boolean isLockedByPrototype() { >> return lockedByPrototype; >> } >> >> public void setLockedByPrototype(boolean lockedByPrototype) { >> this.lockedByPrototype = lockedByPrototype; >> } >> >> @Column(name="requiresPrototype") >> public boolean isRequiresPrototype() { >> return requiresPrototype; >> } >> >> public void setRequiresPrototype(boolean requiresPrototype) { >> this.requiresPrototype = requiresPrototype; >> } >> } > > > >