Can't get arraylist/vector type attributes


I have a class that contains some attributes of type Vector (also tried with ArrayList and same happens). When I try to get an object from that class doing using the find method it works fine, I get the object. But when I call the close method to close the EntityManager the information from the Vector dissapears and I get an empty vector.

Something weird happens, if BEFORE closing the entitymanager I write something like vector.size() or I print it's size or I do anything with the vector, after calling the close method the information from the Vector doesn't disappear.

What am I doing wrong?


By default, collections are retreived from the database lazily, and only when the containing entity objects are managed. i.e. when the EntityManager is open.

When you close the EntityManager managed entity objects become detached, and content that has not been retrieved from the datbase already is not available.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

And what should I do to keep the information?


Access it before closing the EntityManager or load it eagerly (FetchType.EAGER).

See also "" as a possible quick workaround.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Loading it eagerly worked

Post Reply

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