kn_pavan kn_pavan - 2 months ago 27
Java Question

Morphia: Index on collection using deprecated configuration options (Composite key Index)

Recently we have upgraded from Morphia 0.99 to 1.2.x and MongoDB to 3.2.

After that we are seeing a lot of WARNING messages while using collection objects, which are having composite key indexes.

Sample warning is as follows:

WARNING: This index on 'RowData' is
using deprecated configuration options. Please update to use the
fields value on @Index:
@org.mongodb.morphia.annotations.Index(unique=false, dropDups=false,
name=, background=false, expireAfterSeconds=-1, value=resultSetId,
rowSequence, disableValidation=false, sparse=false, fields=[],
dropDups=false, name=, background=false, expireAfterSeconds=-1,
disableValidation=false, language=, languageOverride=, sparse=false))

Index tag on Object is as follows:

@Entity(noClassnameStored = true)
@Indexes({@Index("resultSetId, rowSequence")})
public class RowData implements Transportable { ... }

Is there any way to suppress the warning messages?


no need to suppress the warning, it's there to tell you the configuration you are using will not be supported soon.

try this one instead

    @Index(fields = {@Field(value = "resultSetId"), @Field("rowSequence")})

Note on IndexOptions:
If migrating from older Index syntax to latest, either leave the IndexOptions part altogether (like above) or make sure you are setting the same options as-is on your collection before change. Otherwise, you will get an exception related to IndexOptions.