Question

I was wondering if anyone has attempted and been successful at using the Morphia jar for interacting with a mongodb database inside of GWT? I've been using the below object as the base for all my POJO's, however whenever I attempt to save down the object using an UpdateOperations<DerivedPersistentEntity> or datastore.Save() I get a ConcurrentModificationException.

package com.greycells.dateone.shared;

import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.annotations.Version;

public class PersistentEntity {

    @Id
    private String id;
    @Version
    private Long version = null;

    public PersistentEntity() {
    }

    public String getId() {
        return id;
    }

    public Long getVersion() {
        return version;
    }

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

I've also added the gwt extension jar that you have to download separately for Morphia and referenced it in my gwt.xml and this seems to be of no help. Additionally I've tried changing the id field of PersistentEntity to the ObjectId type but then I can't even get my project to bind correctly because it complains of...

[ERROR] No source code is available for type org.bson.types.ObjectId; did you forget to inherit a required module?

Was it helpful?

Solution

You can't use a String for the @Id field of the entity in Morphia it must be an ObjectId. GWT support in Morphia is completely broken as of v1.02.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top