1

Spring-data for mongodb treats fields named "id" special: http://static.springsource.org/spring-data/data-mongo/docs/1.0.0.M5/reference/html/#d0e1508, in that it tries to map a field named id to the _id field in MongoDB. Is there a way to disable this behavior? I'd like the mongodb ObjectId only mapped to fields with the explicit @Id annotation. Currently I have fields named id in mongodb, and this is not something I can change, and I'm finding it to be near impossible to get spring-data to map the correct id value back into the pojo.

4

1 回答 1

0

当前版本的 Spring Data MongoDB (1.2.0.RELEASE) 将拒绝具有多个 id 属性(注释或默认属性)的类。如果您认为我们应该对此更加宽容(如果属性明确注释,则忽略所有默认属性@Id),请随时在我们的JIRA中打开一张票。当前行为的实现是为了急切地发现从默认映射移动到显式注释时可能发生的潜在错误配置。

于 2013-02-13T08:29:23.777 回答