With our support for encoding/decoding Java records introduced in the 4.6.0 release, the driver introduced new annotations in the org.bson.codecs.record.annotations package (in the bson-record-codec module). The three annotations, BsonId, BsonRepresentation, and BsonProperty, mirror the already-existing ones that we have for POJOs in org.bson.codecs.pojo.annotations package (in the bson module). There are two problems with these annotations:
- mongodb-driver-core takes an implementation rather than an api dependency on bson-record-codec. This means that applications that depend on core (usually via driver-sync) won't be able to reference these annotations unless they take an explicit dependency on bson-record-codec
- The existing annotations can accidentally be applied even to records, but the driver ignores them. This will be really confusing to application authors.
We need to make a decision here. The two obvious choices are:
- Continue down the path of separate annotations for records and POJOs. For this route, we should
- Change the dependency to api so that applications will automatically have access to the annotations without explicitly adding a dependency on {
Unknown macro: {bson-record-codec}
}
- Report runtime errors if RecordCodec detects any of the pojo annotations
- Change the dependency to api so that applications will automatically have access to the annotations without explicitly adding a dependency on {
- Support the pojo annotations in our record encoder/decoder. For this path, we should additionally deprecate the new annotations and stop documenting them.
- related to
-
JAVA-3567 Support Java record types
- Closed