【发布时间】:2011-10-10 10:20:46
【问题描述】:
spring-data 1.0.0.M3 与 MongoDB。 spring怎么能映射这个类:
import org.springframework.data.document.mongodb.index.IndexDirection;
import org.springframework.data.document.mongodb.mapping.Document;
@Document
public class EnumsMapper {
private IndexDirection d = IndexDirection.ASCENDING;
}
这个失败了:
import org.springframework.data.document.mongodb.index.IndexDirection;
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});
}
带有:
java.lang.IllegalArgumentException: can't serialize class org.springframework.data.document.mongodb.index.IndexDirection
同样的情况也发生在其他集合(集合、...)以及数组中。显然spring可以映射这个枚举,所以写一个mapper并不能解决问题。这是一个错误还是有办法映射一个包含枚举的集合(集合/映射)?
【问题讨论】:
标签: mongodb spring-data