PDA

View Full Version : mapping list of enums



amavisto
Jul 14th, 2011, 06:02 PM
Hi,

spring-data 1.0.0.M3 with MongoDB. How come spring can map this class:



import org.springframework.data.document.mongodb.index.In dexDirection;
import org.springframework.data.document.mongodb.mapping. Document;

@Document
public class EnumsMapper {
private IndexDirection d = IndexDirection.ASCENDING;
}



and fails for this one with
java.lang.IllegalArgumentException: can't serialize class org.springframework.data.document.mongodb.index.In dexDirection



import org.springframework.data.document.mongodb.index.In dexDirection;
import org.springframework.data.document.mongodb.mapping. Document;
import java.util.List;
import java.util.Arrays;

@Document
public class EnumsMapper {
List<IndexDirection> list_enum_test = Arrays.asList(new IndexDirection[] {IndexDirection.ASCENDING});

}


The same applies to other collections, and also arrays. Obviously spring can map this enum,
so writing a mapper doesn't solve the problem. Is this a bug or there's a way to map a collection (set/map) holding enums?


thanks,
ms