Issue Details (XML | Word | Printable)

Key: OPENJPA-281
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Kevin Sutter
Reporter: Kevin Sutter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenJPA

EAGER not the default fetch type without the @Basic annotation

Created: 09/Jul/07 02:09 PM   Updated: 05/Aug/07 11:51 PM
Return to search
Component/s: jpa
Affects Version/s: 0.9.7
Fix Version/s: 1.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works openjpa-281.patch 2007-08-02 01:12 PM Kevin Sutter 15 kB

Resolution Date: 05/Aug/07 11:51 PM


 Description  « Hide
There's an on-going discussion on the dev mailing list concerning this problem (http://www.nabble.com/Eager-fetching-not-working-with-enums-and-lobs-tf4037105.html). Since I've gotten agreement on at least one aspect of the problem, I decided to open this JIRA Issue to document the problem.

Here's a summary of the problem:

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;

The JPA spec attempts to address this situation in section 9.1.18... 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?

We're still working on the agreement... :-)

Thanks,
Kevin

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.