bguerout/jongo — pull request #120 by yamsellem (2013-03-10 11:09:01+00:00)
Title: Extract @ObjectId from @Id

@Id seems to bring confusion; many have tried to use it on an Integer, as if it was an alias for @JsonProperty("_id"). And, because it brings a de/serializer, it can only be used on String.

To avoid such problems, this pull-request extract the de/serializer from @Id into a new annotation, @ObjectId.

This offers two advantages:
— @Id can now be used everywhere as an alias for @JsonProperty("_id")
— @ObjectId is dedicated to String and can be used on document id and document embedded ObjectId (links to other documents)

The documentation can be edited the following way:

// generate it!
public class Friend {
@Id
private Integer key;
}
// equivalent to
public class Friend {
@JsonProperty("_id")
private Integer key;
}
// equivalent to
public class Friend {
private Integer _id;
}

And completed with:

// auto generate
public class Friend {
@ObjectId
private String _id;
}
// equivalent to
public class Friend {
@Id
@ObjectId
private String key;
}
// equivalent to
public class Friend {
private ObjectId _id;
}