Mongo panache - persist operation does not return a result of the insert operation #46631
-
The // MongoOperations.java
private void persist(MongoCollection collection, Object entity) { // This method does not return any thing
ClientSession session = getSession(entity);
if (session == null) {
collection.insertOne(entity); // This method returns InsertOneResult
} else {
collection.insertOne(session, entity);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
/cc @FroMage (panache), @loicmathieu (mongodb,panache) |
Beta Was this translation helpful? Give feedback.
-
The entity will be populated with the ObjectId, so if you need the ObjectId you can simply call So after calling |
Beta Was this translation helpful? Give feedback.
Making the entity extend PanacheMongoEntity worked. The
@BsonId
approach didn't work. Closing this discussion for now. I will probably look into it later.