Can't get arraylist/vector type attributes

#1

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?

#2

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
#3

And what should I do to keep the information?

#4

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

See also "objectdb.temp.no-detach" as a possible quick workaround.

ObjectDB Support
#5

Loading it eagerly worked

Reply