mongoDB hibernate-ogm (5.4.1.Final) remove entity keeps _id field

I am using hibernate-ogm and Apache Deltaspike Data to save and remove a simple entity in mongoDB.

Saving works. But removing an entity, empty all fields except _id.

@Entity
public class MyEntity implements Serializable {

    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid2")
    private String id;

    @NotNull
    private String name;

    @Version
    private Integer version;

    @ElementCollection
    private Map<String, String> myMap;

    public MyEntity() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<String, String> getMyMap() {
        return myMap;
    }

    public void setMyMap(Map<String, String> myMap) {
        this.myMap = myMap;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

}

Correctly saved in mongodB

> db.MyEntity.find().pretty()
{
    "_id" : "b359df37-d108-46c7-8c30-ae14c4064e00",
    "name" : "my entity name",
    "version" : 0,
    "myMap" : {
        "key1" : "value1",
        "key2" : "value2"
    }
}

Entity can’t be ‘entirely’ removed using hibernate-ogm and Deltaspike Data myRepository.attachAndRemove(myEntity) method. All fields are removed except “_id”.

> db.MyEntity.find().pretty()
{ "_id" : "b359df37-d108-46c7-8c30-ae14c4064e00" }

However, if I don’t use @Version, the entity is removed completely.

Any explanation for this behaviour/issue and how to avoid it is welcome.

Thanks in advance

It seems like a bug in Hibernate OGM. I can replicate the problem with the example you have provided.
I don’t have a workaround at the moment but I’m still working on it.

workaround:

        EntityTransaction tx = em.getTransaction();
        tx.begin();
        em.createNativeQuery("db.MyEntity.remove({_id:\"" + entity.getId() + "\"})").executeUpdate();
        tx.commit();