multi thread application, id field sporadically null

#1

We are testing objectDB with a multi thread application. Each thread has it's own entityManager created from a common factory.

In one thread we receive sometimes an object from the database with the field that is declared as @Id having the value null (what is not correct, we checked that with the explorer). The class is declared like this:

...

@Entity
public class ObjectNode implements Serializable {
private static final long serialVersionUID = 1L; 
   
@Id
public String nodePath;

...

as soon as we have this behavior exactly this object has always this value for the field even if we query again and again.

any idea ?

#2

We need more information in order to be able to understand the problem.

If you can share a test case it would be perfect.

If not, please explain how exactly you create, persist and retrieve the objects. Except the id field, are other fields initialized correctly? Anything special in the thread in which you have the issue? Do you use enhanced classes?

It seems impossible to retrieve an object from the database without its id, since the first thing in every object retrieval is setting the id. Maybe you retrieve a cached object from memory, which is a new object that has no id yet. You may want to check if using a new EntityManager with an empty cache makes a difference, as well as disabling caches in the configuration. You may also try refreshing the object (although without id id doesn't represent anything in the database, so it may fail).

Again, if you can provide a test case it would be helpful.

ObjectDB Support
#3

we managed to overcome the problem by using flush(), clear() and refresh() 

#4

Good. See also this manual page, regarding setting a flush mode.

ObjectDB Support

Reply