Skip to content

Map value keeps recreating #1063

Open
Open

Description

@VinceCastro

I have a Map<enum_type, Map<String, my_class>> where the value Map<String, my_class> of any entry I add keeps resetting to a new HashMap.

The DB is created this way:
var db = DBMaker.fileDB(db_path).transactionEnable().make();

whereas the map itself is created this way:
Map<enum_type, Map<String, my_class>> my_map = (Map<enum_type, Map<String, my_class>>) db.hashMap(name).createOrOpen();

What could be the cause of this issue?

Activity

  1. hiSandog commented on Jul 3, 2026

    @hiSandog

    This may be a serialization/mutability issue rather than MapDB recreating the value by itself. If the nested Map<String, my_class> is a normal HashMap, each update needs to write the modified value back to the outer map, and the value serializer must be able to serialize my_class deterministically. A minimal example showing whether the nested map is mutated after put, whether db.commit() is called, and which serializer is configured would make the behavior much clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions