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.

public class MyEntity implements Serializable {

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

    private String name;

    private Integer version;

    private Map<String, String> myMap;

    public MyEntity() {

    public String getId() {
        return id;

    public void setId(String id) { = id;

    public String getName() {
        return name;

    public void setName(String 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.


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