removed objects stay with null field values in the reference

#1

We have a class with a one to many relationship declared like this (1 or more objects of the same class are linked into the relationship, no circular referencing):

@Entity
public class ObjectNode implements Serializable {

private static final long serialVersionUID = 1L;

@Id
public String uUid;

...

@OneToMany(fetch=FetchType.LAZY)

public Set<ObjectNode> workflow = new HashSet<ObjectNode>();

When we remove an object that is in this relationship (workflow), the object stays in the relationship with all fields set to null except the primary key. The same behavior is when we 

  • delete with a query
  • use entityManager.remove 
#2

You have to remove the object from the set explicitly, in addition to deleting it.

However, if the set is defined as mapped by, it will be updated automatically after committing the delete operation and then reloading of the object that contains the set from the database, even if the object is not removed from the set explicitly.

ObjectDB Support
#3

just to make sure:

after the deleting or removing of the object at least a kind of invalidated remaining sceleton is still in the database and loaded by a subsequent lazy loading ?

#4

No, after deleting an object it does not exist in the database anymore.

But you may still have broken references to that object, like links to a web page that doesn't exist.

ObjectDB Support

Reply