Search in sources :

Example 16 with MappingException

use of org.mongodb.morphia.mapping.MappingException in project morphia by mongodb.

the class DatastoreImpl method createRef.

@Override
public <T> DBRef createRef(final T entity) {
    final T wrapped = ProxyHelper.unwrap(entity);
    final Object id = mapper.getId(wrapped);
    if (id == null) {
        throw new MappingException("Could not get id for " + wrapped.getClass().getName());
    }
    return createRef(wrapped.getClass(), id);
}
Also used : DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) MappingException(org.mongodb.morphia.mapping.MappingException)

Aggregations

MappingException (org.mongodb.morphia.mapping.MappingException)16 DBObject (com.mongodb.DBObject)9 BasicDBObject (com.mongodb.BasicDBObject)8 MappedClass (org.mongodb.morphia.mapping.MappedClass)7 Test (org.junit.Test)3 MappedField (org.mongodb.morphia.mapping.MappedField)3 WriteResult (com.mongodb.WriteResult)2 GenericArrayType (java.lang.reflect.GenericArrayType)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 TypeVariable (java.lang.reflect.TypeVariable)2 WildcardType (java.lang.reflect.WildcardType)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 BsonDocument (org.bson.BsonDocument)2 NotSaved (org.mongodb.morphia.annotations.NotSaved)2 UpdateException (org.mongodb.morphia.query.UpdateException)2 DBCollection (com.mongodb.DBCollection)1 IOException (java.io.IOException)1 BsonString (org.bson.BsonString)1