Lazy retrieval by access not working correctly

Type: BugPriority: NormalStatus: ClosedReplies: 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 {

private LocalizedValues names;


public class LocalizedValues implements Serializable {

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

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

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
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login