Repository: quarkusio/quarkus
Issue: Issue with id population when using MongoDb with Panache in native

### Describe the bug

When persisting an entity in mongodb, it should populate the id.
It is working launching quarkus in dev mode, but when I build it natively id keeps being null.

### Expected behavior

When persisting, it should populate the value of the generated _id in mongodb.

### Actual behavior

Value is null after persisting

### How to Reproduce?

Get repo:
https://github.com/ZimiZones/mongodb-id-generation

Launch MongoDb:
`docker run --rm -d --name mongo -p 27017:27017 mongo:6.0.4`

Launch in dev:
`quarkus dev`

Send request:
`curl --location 'http://localhost:8080/fasta_dbs'`

It should return:
{"id":"something here","name":"random name"}

It is working!

Build natively:
./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true

Launch and run the same request.
Record had been created in mongodb but you will have an error because id is null.

### Output of `uname -a` or `ver`

Linux WSL

### Output of `java -version`

17.0.4

### GraalVM version (if different from Java)

22.3.1.r17-grl

### Quarkus version or git rev

2.16.2.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

Gradle 8.0

### Additional information

_No response_

Changed files:
extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java

diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
index add4b85f039..4d8fc91bfa4 100644
--- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
+++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/MongoClientProcessor.java
@@ -161,11 +161,13 @@ List<ReflectiveClassBuildItem> addExtensionPointsToNative(CodecProviderBuildItem
         reflectiveClassNames.addAll(commandListeners.getCommandListenerClassNames());
 
         List<ReflectiveClassBuildItem> reflectiveClass = reflectiveClassNames.stream()
-                .map(s -> new ReflectiveClassBuildItem(true, true, false, s))
+                .map(s -> ReflectiveClassBuildItem.builder(s).methods(true).build())
                 .collect(Collectors.toCollection(ArrayList::new));
         // ChangeStreamDocument needs to be registered for reflection with its fields.
-        reflectiveClass.add(new ReflectiveClassBuildItem(true, true, true, ChangeStreamDocument.class.getName()));
-        reflectiveClass.add(new ReflectiveClassBuildItem(true, true, false, UpdateDescription.class.getName()));
+        reflectiveClass.add(ReflectiveClassBuildItem.builder(ChangeStreamDocument.class).methods(true).fields(true).build());
+        reflectiveClass.add(ReflectiveClassBuildItem.builder(UpdateDescription.class).methods(true).build());
+        // ObjectId is often used on identifier, so we also register it
+        reflectiveClass.add(ReflectiveClassBuildItem.builder(ObjectId.class).methods(true).fields(true).build());
         return reflectiveClass;
     }
 
diff --git a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
index b36e8f46a0e..09ef71fb729 100644
--- a/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
+++ b/extensions/panache/mongodb-panache-common/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/BasePanacheMongoResourceProcessor.java
@@ -279,7 +279,7 @@ protected void processEntities(CombinedIndexBuildItem index,
             transformers.produce(new BytecodeTransformerBuildItem(modelClass, entityEnhancer));
 
             //register for reflection entity classes
-            reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, modelClass));
+            reflectiveClass.produce(ReflectiveClassBuildItem.builder(modelClass).fields(true).methods(true).build());
 
             // Register for building the property mapping cache
             propertyMappingClass.produce(new PropertyMappingClassBuildStep(modelClass));