openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgarret <>
Subject Lazy loading not working.
Date Wed, 03 Oct 2007 16:35:48 GMT


I am have several fields that are being eagerly loaded when they should not
be. Here's a simple example to illustrate my problem:

public class Test {

  private TestEnumeration testEnum; // TestEnumeration is an enumeration (go

  private TestBean testBean; // TestObject is just a regular bean

  @ManyToOne( fetch = FetchType.LAZY )
  @Column( name = "test_enumeration_id", nullable = false )
  public TestEnumeration getTestEnum( ) {
    return testEnum;

  @OneToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
  @JoinColumn( name = "test_bean_id", nullable = false, updatable = false )
  public TestBean getTestBean( ) {
    return testBean;


I have made certain that neither testBean nor testEnum are in any active
fetch groups and yet they are still eagerly fetched. According to my logs
they are not fetched due to being accessed, rather, they are pulled
immediately as if they were in a fetch group or declared eager. 

I do not have this issue with collections (OneToMany) and if in the above
example I change the annotation on testEnum from
@ManyToOne(fetch=FetchType.LAZY) to @Basic(fetch=FetchType.LAZY) it behaves

In summation, all of my non-collection joined fields seem get fetched
eagerly despite being defined as lazy and not being in any active fetch

Am I doing something wrong or is this a bug?


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

View raw message