openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxvs <>
Subject OpenJPA retrieving one column a seperate select
Date Tue, 25 Mar 2014 18:51:27 GMT
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)
        @JoinColumn(name = "RAPPORTNR", referencedColumnName = "RAPPORTNR"),
        @JoinColumn(name = "RAPPORTTYPE", referencedColumnName =
private List<Raptaalmetadata> raptaalmetadata;
Queried using Criteria API as follows:
Join<LogischRapport, Raptaalmetadata> metadata = reportRoot.join(

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:

@Column(name = "REPORT_COMMENTS")
private byte[] reportComments;

I now get tons of these:

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.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

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message