Issue #2177: Collection update does not increase entity version and is not persisted

Type: Bug ReoprtVersion: 2.7.3Priority: NormalStatus: FixedReplies: 3


I found a bug when adding elements to a collection of Entities:

Event {
    Collection<Attachment> attachments;

    void addAttachment(Attachment attachment) {
Attachment {
    String filename

If I call this method (all classes are enhanced) the version of the event does not increase and the updated event is not stored in the database (retrieve the event shows that the attachments field is still empty).

You find a complete use case at After Download please start the Tester. It loads an existing Event, adds an attachment via addAttachment() method and checks in another transaction if this change was written or not. If I change the code to use the setAttachments() it also fails.

This is very urgent for us since we already lost important data because of this bug.

Thanks in advance
Markus Ritter


Your test case demonstrates an issue in tracking changes to a collection in an object of an old schema, in which the collection was not exist yet (as of changing attachment to attachments in Event).

As a workaround, you may want to move this initialization:

    private ArrayList<Attachment> attachments = new ArrayList<>();

to getAttachments():

public Collection<Attachment> getAttachments()
    if (attachments == null)
        attachments = new ArrayList<>();
    return attachments;

and update addAttachment and setAttachments to use getAttachments() instead of direct field access.

This workaround may fit as an urgent solution.

ObjectDB Support


this workaround helps but does not solve the core issue. Will there be a fixed version anytime in the near future?

Thanks in advance


Please try build 2.7.3_03.

Note that using the suggested workaround is recommended as it is more efficient. If the ArrayList is initialised as in your original code, ObjectDB has to fall back to tracking changes by comparing object snapshots, which is less efficient.

ObjectDB Support