From dev-return-4807-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Mon Jul 09 16:29:16 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 14154 invoked from network); 9 Jul 2007 16:29:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jul 2007 16:29:15 -0000 Received: (qmail 75043 invoked by uid 500); 9 Jul 2007 16:29:18 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 75012 invoked by uid 500); 9 Jul 2007 16:29:18 -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 75003 invoked by uid 99); 9 Jul 2007 16:29:17 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jul 2007 09:29:17 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [192.18.43.132] (HELO sca-es-mail-1.sun.com) (192.18.43.132) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jul 2007 09:29:14 -0700 Received: from fe-sfbay-09.sun.com ([192.18.43.129]) by sca-es-mail-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id l69GSrbl028340 for ; Mon, 9 Jul 2007 09:28:53 -0700 (PDT) Received: from conversion-daemon.fe-sfbay-09.sun.com by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JKX00L016VPWM00@fe-sfbay-09.sun.com> (original mail from Craig.Russell@Sun.COM) for dev@openjpa.apache.org; Mon, 09 Jul 2007 09:28:53 -0700 (PDT) Received: from [129.145.132.68] by fe-sfbay-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JKX003Y3745E210@fe-sfbay-09.sun.com> for dev@openjpa.apache.org; Mon, 09 Jul 2007 09:28:53 -0700 (PDT) Date: Mon, 09 Jul 2007 09:28:50 -0700 From: Craig L Russell Subject: Re: Eager fetching not working with enums and lobs In-reply-to: <89c0c52c0707090917i6f947c36wc6d93aa218899809@mail.gmail.com> Sender: Craig.Russell@Sun.COM To: dev@openjpa.apache.org Message-id: MIME-version: 1.0 X-Mailer: Apple Mail (2.752.3) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-46--467099629; micalg=sha1 References: <89c0c52c0707061028q3cf343bdi63e0b425ae9164e7@mail.gmail.com> <7262f25e0707061052q1cce9ae6wcbbaa97ecb7b9b76@mail.gmail.com> <89c0c52c0707061137n52cf08c9l7452b978591a6312@mail.gmail.com> <89c0c52c0707081906u2c2c3f98ged82ecfe55539c@mail.gmail.com> <89c0c52c0707090710lce409bna6406b7af97237ca@mail.gmail.com> <7262f25e0707090818h35768c95udadf0f36757a9b86@mail.gmail.com> <89c0c52c0707090917i6f947c36wc6d93aa218899809@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail-46--467099629 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed As I've already said, the spec is pretty opaque. Before assuming that a missing @Basic annotation still has a default fetch=EAGER element, I'd want to see a spec clarification. Clearly there is no TCK test possible for this... Craig On Jul 9, 2007, at 9:17 AM, Kevin Sutter wrote: > :-) The only reason why I would want to eagerly fetch LOBs is to > satisfy > the intent of the spec. Since the @Basic annotation is optional > and the > default fetchType is EAGER, then I assert that the spec indicates > that LOBs > need to be fetched EAGERly. Do you read the spec differently? > > I will agree that "in practice" LOBs should not be fetched > EAGERly. But, we > need to be consistent with the spec so as not to surprise customers > as they > move from one JPA implementation to another. > > Kevin > > On 7/9/07, Patrick Linskey wrote: >> >> Indeed you do... why would we want to eagerly fetch LOBs? I >> understand >> the logic if @Basic is specified, but not if it is omitted. >> >> -Patrick >> >> On 7/9/07, Kevin Sutter wrote: >> > I have opened JIRA Issue 281 ( >> > https://issues.apache.org/jira/browse/OPENJPA-281) for this >> problem. It >> > seems that we have agreed that enums should be EAGER by >> default. I just >> > have to convince everybody that lobs also have to be EAGER, by >> default... >> > :-) >> > >> > Thanks, >> > Kevin >> > >> > On 7/8/07, Kevin Sutter wrote: >> > > >> > > Craig, >> > > Comments below... >> > > >> > > On 7/7/07, Craig L Russell wrote: >> > > > >> > > > Hi Kevin, >> > > > >> > > > If you can figure out what the spec (9.1.18 and 9.1.19) sez, my >> hat's >> > > > off to you. What a mudbake this is. >> > > >> > > >> > > Isn't that just standard order of business with these specs? :-) >> > > >> > > Part of the issue is the annotation definition. If @Basic is >> > > > specified, and the user doesn't explicitly override the >> fetch type, >> > > > it appears to our annotation processor as if the user specified >> > > > EAGER. Even if @Basic is used with @Lob, if lazy is wanted, >> it has >> to >> > > > be explicitly stated. >> > > >> > > >> > > That's how I read the spec. The first paragraph of 9.1.18 >> indicates >> that >> > > @Basic can be applied to any those types (enums and lob types >> included). >> > > The default fetchType is EAGER. It also states that @Basic is >> optional. >> > > So, the way I read this is that we should be doing EAGER >> fetching for >> all of >> > > those listed types unless explicitly told to do otherwise via >> the LAZY >> > > fetchType via an @Basic annotation. >> > > >> > > Maybe we should discuss @Lob in more detail. It isn't obvious >> to me >> > > > that @Basic can always be used and we might have an option >> to choose >> > > > a better default for the fetch behavior if @Basic annotation is >> omitted. >> > > >> > > >> > > It seems to me that the spec is clear on the use and >> expectations of >> > > @Basic and the default fetchType of EAGER. Unless there are >> other >> spec >> > > references that contradict the statements in 9.1.18... >> > > >> > > Craig >> > > > >> > > > On Jul 6, 2007, at 11:37 AM, Kevin Sutter wrote: >> > > > >> > > > > I guess the spec is a bit clearer on this than I first >> thought. >> > > > > Section >> > > > > 9.1.8 of the JPA spec indicates that @Basic is optional and >> applies >> > > > > to the >> > > > > following types: >> > > > > >> > > > > "..Java primitive types, wrappers of the primitive types, >> > > > > java.lang.String, >> > > > > java.math.BigInteger, >> > > > > java.math.BigDecimal, java.util.Date, java.util.Calendar, >> > > > > java.sql.Date, >> > > > > java.sql.Time, java.sql.Timestamp, byte[], Byte[], char[], >> Character >> > > > > [], >> > > > > enums, and any other type that implements Serializable." >> > > > > >> > > > > And, since the default fetch type for @Basic is EAGER, it >> looks >> > > > > like we need >> > > > > to do eager fetching for both @Enumerated and @Lob fields >> unless >> > > > > otherwise >> > > > > overridden by a LAZY fetch type (ie. @Basic(fetch=LAZY)). >> Agree? >> > > > > >> > > > > Kevin >> > > > > >> > > > > On 7/6/07, Craig L Russell wrote: >> > > > >> >> > > > >> >> > > > >> On Jul 6, 2007, at 10:52 AM, Patrick Linskey wrote: >> > > > >> >> > > > >> > The spec doesn't seem to discuss it, but I think that >> lazy is a >> > > > >> pretty >> > > > >> > good default behavior for @Lob field types -- typically >> @Lob >> things >> > > > >> > are big, so you often don't want them in the default fetch >> graph. >> > > > >> >> > > > >> Enum is different, though. Enum should be eager fetching by >> default. >> > > > >> >> > > > >> Lazy fetching is optional, so we can decide what we want >> to do. >> It >> > > > >> seems that the existence of @Basic should not change our >> strategy. >> > > > >> And we should default to lazy fetching for Lob and eager >> fetching >> for >> > > > >> > > > >> Enum. >> > > > >> >> > > > >> Craig >> > > > >> > >> > > > >> > -Patrick >> > > > >> > >> > > > >> > On 7/6/07, Kevin Sutter wrote: >> > > > >> >> I am finding that the supposed default action of Eager >> fetching is >> > > > >> >> not >> > > > >> >> happening with @Enumerated and @Lob fields. If I >> explicitly >> > > > >> >> specify the >> > > > >> >> @Basic annotation, then the fields are eagerly >> fetched. But, >> > > > >> >> without this >> > > > >> >> extraneous @Basic, these fields are lazily loaded. This >> action >> > > > >> >> does not >> > > > >> >> seem to be consistent with the spec. Nor, can I find any >> mention >> > > > >> >> of this >> > > > >> >> alternate behavior in our OpenJPA manual. Sounds like >> a bug >> to >> > > > >> >> me. Any >> > > > >> >> other insights? >> > > > >> >> >> > > > >> >> This works (eager loading kicks in): >> > > > >> >> >> > > > >> >> @Basic @Enumerated(EnumType.STRING) >> > > > >> >> private Gender gender; >> > > > >> >> >> > > > >> >> This does not work (lazy loading kicks in): >> > > > >> >> >> > > > >> >> @Enumerated(EnumType.STRING) >> > > > >> >> private Gender gender; >> > > > >> >> >> > > > >> >> I have also tried to use defaults (without any >> annotations), >> > > > >> and lazy >> > > > >> >> loading still kicks in: >> > > > >> >> >> > > > >> >> private Gender gender; >> > > > >> >> >> > > > >> >> Thanks, >> > > > >> >> Kevin >> > > > >> >> >> > > > >> > >> > > > >> > >> > > > >> > -- >> > > > >> > Patrick Linskey >> > > > >> > 202 669 5907 >> > > > >> >> > > > >> Craig Russell >> > > > >> Architect, Sun Java Enterprise System >> http://java.sun.com/products/ >> > > > >> jdo >> > > > >> 408 276-5638 mailto: Craig.Russell@sun.com >> > > > >> P.S. A good JDO? O, Gasp! >> > > > >> >> > > > >> >> > > > >> >> > > > >> > > > Craig Russell >> > > > Architect, Sun Java Enterprise System >> http://java.sun.com/products/jdo >> > > > 408 276-5638 mailto:Craig.Russell@sun.com >> > > > P.S. A good JDO? O, Gasp! >> > > > >> > > > >> > > > >> > > >> > >> >> >> -- >> Patrick Linskey >> 202 669 5907 >> Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:Craig.Russell@sun.com P.S. A good JDO? O, Gasp! --Apple-Mail-46--467099629 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICECpJVMO68ii+Xfsc1O1YYFIwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLD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