Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9724010BC1 for ; Tue, 25 Mar 2014 18:52:02 +0000 (UTC) Received: (qmail 34018 invoked by uid 500); 25 Mar 2014 18:52:02 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 33768 invoked by uid 500); 25 Mar 2014 18:51:57 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 33744 invoked by uid 99); 25 Mar 2014 18:51:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2014 18:51:53 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of mxvs112@gmail.com does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Mar 2014 18:51:48 +0000 Received: from jim.nabble.com ([192.168.236.80]) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WSWRb-0000UC-3s for users@openjpa.apache.org; Tue, 25 Mar 2014 11:51:27 -0700 Date: Tue, 25 Mar 2014 11:51:27 -0700 (PDT) From: mxvs To: users@openjpa.apache.org Message-ID: <1395773487043-7586156.post@n2.nabble.com> Subject: OpenJPA retrieving one column a seperate select MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hello, I've been using OpenJPA 2.1.2 (JPA 2.0) to retrieve data from a table called LOGISCHRAPPORT which has about 28 columns. In some cases OpenJPA decides to issue seperate select statements for one of the columns for no particular reason, leading to a dramatic decrease in query performance. Initially everything goes fine and all my columns are retrieved in a performant, single SELECT statement by JPA. As soon as I add a relationship to another entity called RAPTAALMETADATA @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL) @JoinColumns({ @JoinColumn(name = "RAPPORTNR", referencedColumnName = "RAPPORTNR"), @JoinColumn(name = "RAPPORTTYPE", referencedColumnName = "RAPPORTTYPE") }) private List raptaalmetadata; --- Queried using Criteria API as follows: --- Join metadata = reportRoot.join( "raptaalmetadata"); JPA no longer includes one of my original columns called REPORT_COMMENTS instead it is issuing separate select statements to retrieve the REPORT_COMMENTS column for each instance of LOGISCHRAPPORT. All other columns (including the ones coming from RAPTAALMETADATA are retrieved properly as part of the intial SELECT. REPORT_COMMENTS is of the HUGEBLOB type in Oracle and I've mapped in in my Entity as follows: @Lob @Basic @Column(name = "REPORT_COMMENTS") private byte[] reportComments; I now get tons of these: SELECT t0.REPORT_COMMENTS FROM dwhsd001.LogischRapport t0 WHERE t0.rapportnr = ? AND t0.rapporttype = ? [params=(long) 1473, (String) RAP] Additionally: as soon as I remove the fetch=FetchType.EAGER attribute from the @OneToMany annotation described above I start seeing the exact same behavior for the relationship as I've been getting for the REPORT_COMMENTS column. This means I'm also getting separate SELECT statements for retrieving the entity relationship on top of the seperate selects for the column thereby further degrading performance. In other words I'm then also getting tons of these: SELECT t0.isotaalcode, t0.rapportnr, t0.rapporttype, t0.FUNCDESC_MODIFIED_BY, t0.FUNCDESC_MODIFIED_DATE, t0.FUNCTIONAL_DESCRIPTION, t0.omschrijving, t0.titel FROM dwhsd001.Raptaalmetadata t0 WHERE t0.rapportnr = ? AND t0.rapporttype = ? Its not a LAZY loading problem as I've specifically tested that case. I don't see any other reason why OpenJPA decides to retrieve this one column using separate statements. Can anyone point out why I might be seeing this behavior and how I can avoid it? -- View this message in context: http://openjpa.208410.n2.nabble.com/OpenJPA-retrieving-one-column-a-seperate-select-tp7586156.html Sent from the OpenJPA Users mailing list archive at Nabble.com.