Skip to content

Commit

Permalink
Explain in MongoDB docs that records are supported
Browse files Browse the repository at this point in the history
Fixes #38086
  • Loading branch information
loicmathieu committed Nov 5, 2024
1 parent 91cc2dd commit 8e92160
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/src/main/asciidoc/mongodb-panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ TIP: Using `@BsonProperty` is not needed to define custom column mappings, as th

TIP: You can have your projection class extends from another class. In this case, the parent class also needs to have use `@ProjectionFor` annotation.

TIP: If you run Java 17+, records are a good fit for projection classes.
TIP: Records are a good fit for projection classes.

== Query debugging

Expand All @@ -724,6 +724,7 @@ quarkus.log.category."io.quarkus.mongodb.panache.common.runtime".level=DEBUG

MongoDB with Panache uses the link:{mongodb-doc-root-url}/fundamentals/data-formats/document-data-format-pojo/[PojoCodecProvider], with link:{mongodb-doc-root-url}/fundamentals/data-formats/document-data-format-pojo/#configure-the-driver-for-pojos[automatic POJO support],
to automatically convert your object to a BSON document.
This codec also supports Java records so you can use them for your entities or an attribute of your entities.

In case you encounter the `org.bson.codecs.configuration.CodecConfigurationException` exception, it means the codec is not able to
automatically convert your object.
Expand Down
3 changes: 2 additions & 1 deletion docs/src/main/asciidoc/mongodb.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ public class CodecFruitService {
== The POJO Codec

The link:https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/data-formats/document-data-format-pojo/[POJO Codec] provides a set of annotations that enable the customization of
the way a POJO is mapped to a MongoDB collection and this codec is initialized automatically by Quarkus
the way a POJO is mapped to a MongoDB collection and this codec is initialized automatically by Quarkus.
This codec also supports Java records so you can use them for your POJOs or an attribute of your POJOs.

One of these annotations is the `@BsonDiscriminator` annotation that allows to storage multiple Java types in a single MongoDB collection by adding
a discriminator field inside the document. It can be useful when working with abstract types or interfaces.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
* otherwise it will be the name of your entity.
* </p>
* <p>
* The Mongo PojoCodec is used to serialize your entity to Bson Document, you can find more information on it's
* documentation page: https://mongodb.github.io/mongo-java-driver/3.10/bson/pojos/
* The Mongo PojoCodec is used to serialize your entity to a Bson Document, you can find more information on its
* documentation page:
* https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/data-formats/document-data-format-pojo.
* This codec also supports Java records.
* You can use the MongoDB annotations to control the mapping to the database : <code>@BsonId</code>,
* <code>@BsonProperty("fieldName")</code>, <code>@BsonIgnore</code>.
* </p>
Expand Down

0 comments on commit 8e92160

Please sign in to comment.