ObjectDB ObjectDB

Issue #1456: Lazy retrieval by access not working correctly

Type: Bug ReoprtPriority: NormalStatus: ClosedReplies: 1
#1

I have a problem loading lazy associations by access/navigation with an @Embedded attribute containing an @ElementCollection which is lazy loaded.  I'm not sure if the same problem exists elsewhere.  Furthermore, if I set a breakpoint in the right spot in debug mode, everything works correctly.  Without the breakpoint, my lazy collection does not get loaded.  Here are code snippets which should reproduce the problem.

public class Locale extends BaseEntity {

...

@Embedded
private LocalizedValues names;
...

}


@Embeddable
public class LocalizedValues implements Serializable {

...

@ElementCollection // lazy loaded by default
private Map<Locale, LocalizedValue> values;
...
}


@Stateless
public class MyServiceBean {
...
public Locale getLocaleWithName() {
  Locale locale = entityManager.find(Locale.class, id);
  locale.getNames().getValues(); // should load values from DB
  return locale; // if I set a breakpoint here, values loaded from DB; without breakpoint they are not loaded
}
...
}
edit
delete
#2

Values are not expected to be loaded in this code.

getValues() returns a reference to the map, but should not load the map content.

The content is loaded if you view the map in the debugger, or if your application accesses keys and values in the map.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.