Search in sources :

Example 1 with IdField

use of dev.morphia.annotations.experimental.IdField in project morphia by mongodb.

the class ConfigureProperties method apply.

@Override
public void apply(Mapper mapper, EntityModelBuilder modelBuilder) {
    MapperOptions options = mapper.getOptions();
    processProperties(modelBuilder, options);
    if (modelBuilder.idPropertyName() == null) {
        IdField idProperty = modelBuilder.getAnnotation(IdField.class);
        if (idProperty != null) {
            modelBuilder.idPropertyName(idProperty.value());
            PropertyModelBuilder propertyModelBuilder = modelBuilder.propertyModelByName(idProperty.value());
            propertyModelBuilder.mappedName("_id");
        }
    }
}
Also used : MapperOptions(dev.morphia.mapping.MapperOptions) PropertyModelBuilder(dev.morphia.mapping.codec.pojo.PropertyModelBuilder) IdField(dev.morphia.annotations.experimental.IdField)

Aggregations

IdField (dev.morphia.annotations.experimental.IdField)1 MapperOptions (dev.morphia.mapping.MapperOptions)1 PropertyModelBuilder (dev.morphia.mapping.codec.pojo.PropertyModelBuilder)1