From f3fee5860b229df99463c4fd8cb4de955e55a899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Fri, 23 Aug 2024 10:52:56 +0200 Subject: [PATCH] Use Bson and not Document in MondoDB with Panache methods Fixes #42658 --- .../common/MongoDatabaseResolverTest.java | 9 +- .../mongodb/panache/common/PanacheUpdate.java | 6 +- .../reactive/ReactivePanacheUpdate.java | 6 +- .../runtime/ReactiveMongoOperations.java | 49 ++++---- .../runtime/ReactivePanacheUpdateImpl.java | 3 +- .../common/runtime/MongoOperations.java | 52 ++++----- .../common/runtime/PanacheUpdateImpl.java | 3 +- .../common/runtime/MongoOperationsTest.java | 6 +- .../panache/kotlin/PanacheMongoCompanion.kt | 23 ++-- .../kotlin/PanacheMongoRepositoryBase.kt | 45 ++++--- .../reactive/ReactivePanacheMongoCompanion.kt | 42 +++---- .../ReactivePanacheMongoRepositoryBase.kt | 44 +++---- .../runtime/KotlinReactiveMongoOperations.kt | 13 +-- .../kotlin/runtime/KotlinMongoOperations.kt | 8 +- .../panache/PanacheMongoEntityBase.java | 110 +++++++++--------- .../panache/PanacheMongoRepositoryBase.java | 110 +++++++++--------- .../quarkus/mongodb/panache/PanacheQuery.java | 4 +- .../ReactivePanacheMongoEntityBase.java | 90 +++++++------- .../ReactivePanacheMongoRepositoryBase.java | 108 ++++++++--------- .../runtime/JavaReactiveMongoOperations.java | 6 +- .../panache/runtime/JavaMongoOperations.java | 6 +- 21 files changed, 366 insertions(+), 377 deletions(-) diff --git a/extensions/panache/mongodb-panache-common/deployment/src/test/java/io/quarkus/mongodb/panache/common/MongoDatabaseResolverTest.java b/extensions/panache/mongodb-panache-common/deployment/src/test/java/io/quarkus/mongodb/panache/common/MongoDatabaseResolverTest.java index d75b6b9342354..e83e026a2d52b 100644 --- a/extensions/panache/mongodb-panache-common/deployment/src/test/java/io/quarkus/mongodb/panache/common/MongoDatabaseResolverTest.java +++ b/extensions/panache/mongodb-panache-common/deployment/src/test/java/io/quarkus/mongodb/panache/common/MongoDatabaseResolverTest.java @@ -11,6 +11,7 @@ import org.bson.Document; import org.bson.codecs.pojo.annotations.BsonId; +import org.bson.conversions.Bson; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnOs; @@ -130,12 +131,12 @@ private void assertPerson(final Person expected, final Person value) { private static class CustomMongoOperations extends MongoOperations { @Override - protected Object createQuery(MongoCollection collection, ClientSession session, Document query, Document sortDoc) { + protected Object createQuery(MongoCollection collection, ClientSession session, Bson query, Bson sortDoc) { return null; } @Override - protected PanacheUpdate createUpdate(MongoCollection collection, Class entityClass, Document docUpdate) { + protected PanacheUpdate createUpdate(MongoCollection collection, Class entityClass, Bson docUpdate) { return null; } @@ -155,12 +156,12 @@ protected Stream stream(Object queryType) { private static class CustomReactiveMongoOperations extends ReactiveMongoOperations { @Override - protected Object createQuery(ReactiveMongoCollection collection, Document query, Document sortDoc) { + protected Object createQuery(ReactiveMongoCollection collection, Bson query, Bson sortDoc) { return null; } @Override - protected PanacheUpdate createUpdate(ReactiveMongoCollection collection, Class entityClass, Document docUpdate) { + protected PanacheUpdate createUpdate(ReactiveMongoCollection collection, Class entityClass, Bson docUpdate) { return null; } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/PanacheUpdate.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/PanacheUpdate.java index bc6cdca1fbb3c..6e2c0c5825a1b 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/PanacheUpdate.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/PanacheUpdate.java @@ -2,7 +2,7 @@ import java.util.Map; -import org.bson.Document; +import org.bson.conversions.Bson; import io.quarkus.panache.common.Parameters; @@ -43,10 +43,10 @@ public interface PanacheUpdate { /** * Execute the update query with the update document. * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return the number of entities updated. */ - public long where(Document query); + public long where(Bson query); /** * Execute an update on all documents with the update document. diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/ReactivePanacheUpdate.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/ReactivePanacheUpdate.java index 7bf253bd2c249..18dc831215e5f 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/ReactivePanacheUpdate.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/ReactivePanacheUpdate.java @@ -2,7 +2,7 @@ import java.util.Map; -import org.bson.Document; +import org.bson.conversions.Bson; import io.quarkus.panache.common.Parameters; import io.smallrye.mutiny.Uni; @@ -43,10 +43,10 @@ public interface ReactivePanacheUpdate { /** * Execute the update query with the update document. * - * @param query a {@link org.bson.Document} query + * @param query a {@link Bson} query * @return the number of entities updated. */ - public Uni where(Document query); + public Uni where(Bson query); /** * Execute an update on all documents with the update document. diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java index c0fda7ed87a24..6b912beb4836f 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactiveMongoOperations.java @@ -21,6 +21,7 @@ import org.bson.Document; import org.bson.codecs.Codec; import org.bson.codecs.EncoderContext; +import org.bson.conversions.Bson; import org.jboss.logging.Logger; import com.mongodb.ReadPreference; @@ -56,10 +57,10 @@ public abstract class ReactiveMongoOperations { private static final Map defaultDatabaseName = new ConcurrentHashMap<>(); - protected abstract QueryType createQuery(ReactiveMongoCollection collection, Document query, Document sortDoc); + protected abstract QueryType createQuery(ReactiveMongoCollection collection, Bson query, Bson sortDoc); protected abstract UpdateType createUpdate(ReactiveMongoCollection collection, Class entityClass, - Document docUpdate); + Bson docUpdate); protected abstract Uni list(QueryType query); @@ -284,7 +285,7 @@ private Uni update(ReactiveMongoCollection collection, Object entity) { private Uni update(ReactiveMongoCollection collection, List entities) { List> unis = entities.stream().map(entity -> update(collection, entity)).collect(Collectors.toList()); - return Uni.combine().all().unis(unis).combinedWith(u -> null); + return Uni.combine().all().unis(unis).with(u -> null); } private Uni persistOrUpdate(ReactiveMongoCollection collection, Object entity) { @@ -391,8 +392,8 @@ public QueryType find(Class entityClass, String query, Object... params) { public QueryType find(Class entityClass, String query, Sort sort, Object... params) { String bindQuery = bindFilter(entityClass, query, params); - Document docQuery = Document.parse(bindQuery); - Document docSort = sortToDocument(sort); + Bson docQuery = Document.parse(bindQuery); + Bson docSort = sortToDocument(sort); ReactiveMongoCollection collection = mongoCollection(entityClass); return createQuery(collection, docQuery, docSort); } @@ -490,8 +491,8 @@ public QueryType find(Class entityClass, String query, Map pa public QueryType find(Class entityClass, String query, Sort sort, Map params) { String bindQuery = bindFilter(entityClass, query, params); - Document docQuery = Document.parse(bindQuery); - Document docSort = sortToDocument(sort); + Bson docQuery = Document.parse(bindQuery); + Bson docSort = sortToDocument(sort); ReactiveMongoCollection collection = mongoCollection(entityClass); return createQuery(collection, docQuery, docSort); } @@ -504,19 +505,19 @@ public QueryType find(Class entityClass, String query, Sort sort, Parameters return find(entityClass, query, sort, params.map()); } - public QueryType find(Class entityClass, Document query, Sort sort) { + public QueryType find(Class entityClass, Bson query, Sort sort) { ReactiveMongoCollection collection = mongoCollection(entityClass); - Document sortDoc = sortToDocument(sort); + Bson sortDoc = sortToDocument(sort); return createQuery(collection, query, sortDoc); } - public QueryType find(Class entityClass, Document query, Document sort) { + public QueryType find(Class entityClass, Bson query, Bson sort) { ReactiveMongoCollection collection = mongoCollection(entityClass); return createQuery(collection, query, sort); } - public QueryType find(Class entityClass, Document query) { - return find(entityClass, query, (Document) null); + public QueryType find(Class entityClass, Bson query) { + return find(entityClass, query, (Bson) null); } public Uni> list(Class entityClass, String query, Object... params) { @@ -544,12 +545,12 @@ public Uni> list(Class entityClass, String query, Sort sort, Paramete } //specific Mongo query - public Uni> list(Class entityClass, Document query) { + public Uni> list(Class entityClass, Bson query) { return (Uni) list(find(entityClass, query)); } //specific Mongo query - public Uni> list(Class entityClass, Document query, Document sort) { + public Uni> list(Class entityClass, Bson query, Bson sort) { return (Uni) list(find(entityClass, query, sort)); } @@ -578,12 +579,12 @@ public Multi stream(Class entityClass, String query, Sort sort, Parameters } //specific Mongo query - public Multi stream(Class entityClass, Document query) { + public Multi stream(Class entityClass, Bson query) { return stream(find(entityClass, query)); } //specific Mongo query - public Multi stream(Class entityClass, Document query, Document sort) { + public Multi stream(Class entityClass, Bson query, Bson sort) { return stream(find(entityClass, query, sort)); } @@ -594,11 +595,11 @@ public QueryType findAll(Class entityClass) { public QueryType findAll(Class entityClass, Sort sort) { ReactiveMongoCollection collection = mongoCollection(entityClass); - Document sortDoc = sortToDocument(sort); + Bson sortDoc = sortToDocument(sort); return createQuery(collection, null, sortDoc); } - private Document sortToDocument(Sort sort) { + private Bson sortToDocument(Sort sort) { if (sort == null) { return null; } @@ -662,7 +663,7 @@ public Uni count(Class entityClass, String query, Parameters params) { } //specific Mongo query - public Uni count(Class entityClass, Document query) { + public Uni count(Class entityClass, Bson query) { ReactiveMongoCollection collection = mongoCollection(entityClass); if (Panache.getCurrentSession() != null) { return collection.countDocuments(Panache.getCurrentSession(), query); @@ -680,7 +681,7 @@ public Uni deleteAll(Class entityClass) { public Uni deleteById(Class entityClass, Object id) { ReactiveMongoCollection collection = mongoCollection(entityClass); - Document query = new Document().append(ID, id); + Bson query = new Document().append(ID, id); if (Panache.getCurrentSession() != null) { return collection.deleteOne(Panache.getCurrentSession(), query).map(results -> results.getDeletedCount() == 1); } @@ -712,7 +713,7 @@ public Uni delete(Class entityClass, String query, Parameters params) { } //specific Mongo query - public Uni delete(Class entityClass, Document query) { + public Uni delete(Class entityClass, Bson query) { ReactiveMongoCollection collection = mongoCollection(entityClass); if (Panache.getCurrentSession() != null) { return collection.deleteMany(Panache.getCurrentSession(), query).map(DeleteResult::getDeletedCount); @@ -732,20 +733,20 @@ public UpdateType update(Class entityClass, String update, Object... params) return executeUpdate(entityClass, update, params); } - public UpdateType update(Class entityClass, Document update) { + public UpdateType update(Class entityClass, Bson update) { return createUpdate(mongoCollection(entityClass), entityClass, update); } private UpdateType executeUpdate(Class entityClass, String update, Object... params) { String bindUpdate = bindUpdate(entityClass, update, params); - Document docUpdate = Document.parse(bindUpdate); + Bson docUpdate = Document.parse(bindUpdate); ReactiveMongoCollection collection = mongoCollection(entityClass); return createUpdate(collection, entityClass, docUpdate); } private UpdateType executeUpdate(Class entityClass, String update, Map params) { String bindUpdate = bindUpdate(entityClass, update, params); - Document docUpdate = Document.parse(bindUpdate); + Bson docUpdate = Document.parse(bindUpdate); ReactiveMongoCollection collection = mongoCollection(entityClass); return createUpdate(collection, entityClass, docUpdate); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactivePanacheUpdateImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactivePanacheUpdateImpl.java index 025f1c21f2be8..4bead44adb5dc 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactivePanacheUpdateImpl.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/reactive/runtime/ReactivePanacheUpdateImpl.java @@ -3,7 +3,6 @@ import java.util.Map; import org.bson.BsonDocument; -import org.bson.Document; import org.bson.conversions.Bson; import io.quarkus.mongodb.panache.common.reactive.Panache; @@ -47,7 +46,7 @@ public Uni where(String query, Parameters params) { } @Override - public Uni where(Document query) { + public Uni where(Bson query) { return executeUpdate(query); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/MongoOperations.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/MongoOperations.java index 93f411727938b..5a2b84612ab6c 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/MongoOperations.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/MongoOperations.java @@ -22,6 +22,7 @@ import org.bson.Document; import org.bson.codecs.Codec; import org.bson.codecs.EncoderContext; +import org.bson.conversions.Bson; import org.jboss.logging.Logger; import com.mongodb.ReadPreference; @@ -29,10 +30,7 @@ import com.mongodb.client.MongoClient; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; -import com.mongodb.client.model.InsertOneModel; -import com.mongodb.client.model.ReplaceOneModel; -import com.mongodb.client.model.ReplaceOptions; -import com.mongodb.client.model.WriteModel; +import com.mongodb.client.model.*; import com.mongodb.client.result.DeleteResult; import io.quarkus.arc.Arc; @@ -60,10 +58,10 @@ public abstract class MongoOperations { private final Map defaultDatabaseName = new ConcurrentHashMap<>(); - protected abstract QueryType createQuery(MongoCollection collection, ClientSession session, Document query, - Document sortDoc); + protected abstract QueryType createQuery(MongoCollection collection, ClientSession session, Bson query, + Bson sortDoc); - protected abstract UpdateType createUpdate(MongoCollection collection, Class entityClass, Document docUpdate); + protected abstract UpdateType createUpdate(MongoCollection collection, Class entityClass, Bson docUpdate); protected abstract List list(QueryType queryType); @@ -433,8 +431,8 @@ public QueryType find(Class entityClass, String query, Object... params) { public QueryType find(Class entityClass, String query, Sort sort, Object... params) { String bindQuery = bindFilter(entityClass, query, params); - Document docQuery = Document.parse(bindQuery); - Document docSort = sortToDocument(sort); + Bson docQuery = Document.parse(bindQuery); + Bson docSort = sortToDocument(sort); MongoCollection collection = mongoCollection(entityClass); ClientSession session = getSession(entityClass); return createQuery(collection, session, docQuery, docSort); @@ -529,8 +527,8 @@ public QueryType find(Class entityClass, String query, Map pa public QueryType find(Class entityClass, String query, Sort sort, Map params) { String bindQuery = bindFilter(entityClass, query, params); - Document docQuery = Document.parse(bindQuery); - Document docSort = sortToDocument(sort); + Bson docQuery = Document.parse(bindQuery); + Bson docSort = sortToDocument(sort); MongoCollection collection = mongoCollection(entityClass); ClientSession session = getSession(entityClass); return createQuery(collection, session, docQuery, docSort); @@ -544,20 +542,20 @@ public QueryType find(Class entityClass, String query, Sort sort, Parameters return find(entityClass, query, sort, params.map()); } - public QueryType find(Class entityClass, Document query, Sort sort) { + public QueryType find(Class entityClass, Bson query, Sort sort) { MongoCollection collection = mongoCollection(entityClass); - Document sortDoc = sortToDocument(sort); + Bson sortDoc = sortToDocument(sort); ClientSession session = getSession(entityClass); return createQuery(collection, session, query, sortDoc); } - public QueryType find(Class entityClass, Document query, Document sort) { + public QueryType find(Class entityClass, Bson query, Bson sort) { MongoCollection collection = mongoCollection(entityClass); ClientSession session = getSession(entityClass); return createQuery(collection, session, query, sort); } - public QueryType find(Class entityClass, Document query) { + public QueryType find(Class entityClass, Bson query) { return find(entityClass, query, (Document) null); } @@ -586,12 +584,12 @@ public List list(Class entityClass, String query, Sort sort, Parameters pa } //specific Mongo query - public List list(Class entityClass, Document query) { + public List list(Class entityClass, Bson query) { return list(find(entityClass, query)); } //specific Mongo query - public List list(Class entityClass, Document query, Document sort) { + public List list(Class entityClass, Bson query, Bson sort) { return list(find(entityClass, query, sort)); } @@ -620,12 +618,12 @@ public Stream stream(Class entityClass, String query, Sort sort, Parameter } //specific Mongo query - public Stream stream(Class entityClass, Document query) { + public Stream stream(Class entityClass, Bson query) { return stream(find(entityClass, query)); } //specific Mongo query - public Stream stream(Class entityClass, Document query, Document sort) { + public Stream stream(Class entityClass, Bson query, Bson sort) { return stream(find(entityClass, query, sort)); } @@ -637,12 +635,12 @@ public QueryType findAll(Class entityClass) { public QueryType findAll(Class entityClass, Sort sort) { MongoCollection collection = mongoCollection(entityClass); - Document sortDoc = sortToDocument(sort); + Bson sortDoc = sortToDocument(sort); ClientSession session = getSession(entityClass); return createQuery(collection, session, null, sortDoc); } - private Document sortToDocument(Sort sort) { + private Bson sortToDocument(Sort sort) { if (sort == null) { return null; } @@ -702,7 +700,7 @@ public long count(Class entityClass, String query, Parameters params) { } //specific Mongo query - public long count(Class entityClass, Document query) { + public long count(Class entityClass, Bson query) { MongoCollection collection = mongoCollection(entityClass); ClientSession session = getSession(entityClass); return session == null ? collection.countDocuments(query) : collection.countDocuments(session, query); @@ -717,7 +715,7 @@ public long deleteAll(Class entityClass) { public boolean deleteById(Class entityClass, Object id) { MongoCollection collection = mongoCollection(entityClass); - Document query = new Document().append(ID, id); + Bson query = new Document().append(ID, id); ClientSession session = getSession(entityClass); DeleteResult results = session == null ? collection.deleteOne(query) : collection.deleteOne(session, query); return results.getDeletedCount() == 1; @@ -746,7 +744,7 @@ public long delete(Class entityClass, String query, Parameters params) { } //specific Mongo query - public long delete(Class entityClass, Document query) { + public long delete(Class entityClass, Bson query) { MongoCollection collection = mongoCollection(entityClass); ClientSession session = getSession(entityClass); return session == null ? collection.deleteMany(query).getDeletedCount() @@ -765,19 +763,19 @@ public UpdateType update(Class entityClass, String update, Object... params) return executeUpdate(entityClass, update, params); } - public UpdateType update(Class entityClass, Document update) { + public UpdateType update(Class entityClass, Bson update) { return createUpdate(mongoCollection(entityClass), entityClass, update); } private UpdateType executeUpdate(Class entityClass, String update, Object... params) { String bindUpdate = bindUpdate(entityClass, update, params); - Document docUpdate = Document.parse(bindUpdate); + Bson docUpdate = Document.parse(bindUpdate); return createUpdate(mongoCollection(entityClass), entityClass, docUpdate); } private UpdateType executeUpdate(Class entityClass, String update, Map params) { String bindUpdate = bindUpdate(entityClass, update, params); - Document docUpdate = Document.parse(bindUpdate); + Bson docUpdate = Document.parse(bindUpdate); return createUpdate(mongoCollection(entityClass), entityClass, docUpdate); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/PanacheUpdateImpl.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/PanacheUpdateImpl.java index d35caefeeaee4..c7145f95a875b 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/PanacheUpdateImpl.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/PanacheUpdateImpl.java @@ -3,7 +3,6 @@ import java.util.Map; import org.bson.BsonDocument; -import org.bson.Document; import org.bson.conversions.Bson; import com.mongodb.client.ClientSession; @@ -47,7 +46,7 @@ public long where(String query, Parameters params) { } @Override - public long where(Document query) { + public long where(Bson query) { return executeUpdate(query); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/test/java/io/quarkus/mongodb/panache/common/runtime/MongoOperationsTest.java b/extensions/panache/mongodb-panache-common/runtime/src/test/java/io/quarkus/mongodb/panache/common/runtime/MongoOperationsTest.java index 8a1cb1f0081ef..17050108ac2d1 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/test/java/io/quarkus/mongodb/panache/common/runtime/MongoOperationsTest.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/test/java/io/quarkus/mongodb/panache/common/runtime/MongoOperationsTest.java @@ -15,8 +15,8 @@ import java.util.UUID; import java.util.stream.Stream; -import org.bson.Document; import org.bson.codecs.pojo.annotations.BsonProperty; +import org.bson.conversions.Bson; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -39,12 +39,12 @@ protected Stream stream(Object o) { } @Override - protected Object createUpdate(MongoCollection collection, Class entityClass, Document docUpdate) { + protected Object createUpdate(MongoCollection collection, Class entityClass, Bson docUpdate) { return null; } @Override - protected Object createQuery(MongoCollection collection, ClientSession session, Document query, Document sortDoc) { + protected Object createQuery(MongoCollection collection, ClientSession session, Bson query, Bson sortDoc) { return null; } }; diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt index 4a754cf730469..b484dc47feb3e 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoCompanion.kt @@ -7,7 +7,7 @@ import io.quarkus.panache.common.Parameters import io.quarkus.panache.common.Sort import io.quarkus.panache.common.impl.GenerateBridge import java.util.stream.Stream -import org.bson.Document +import org.bson.conversions.Bson import org.bson.types.ObjectId /** @@ -131,8 +131,7 @@ interface PanacheMongoCompanionBase { * @see [stream] */ @GenerateBridge - fun find(query: Document): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + fun find(query: Bson): PanacheQuery = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. @@ -145,7 +144,7 @@ interface PanacheMongoCompanionBase { * @see [stream] */ @GenerateBridge - fun find(query: Document, sort: Document): PanacheQuery = + fun find(query: Bson, sort: Bson): PanacheQuery = throw INSTANCE.implementationInjectionMissing() /** @@ -274,7 +273,7 @@ interface PanacheMongoCompanionBase { * @see [stream] */ @GenerateBridge - fun list(query: Document): List = throw INSTANCE.implementationInjectionMissing() + fun list(query: Bson): List = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, @@ -288,7 +287,7 @@ interface PanacheMongoCompanionBase { * @see [stream] */ @GenerateBridge - fun list(query: Document, sort: Document): List = + fun list(query: Bson, sort: Bson): List = throw INSTANCE.implementationInjectionMissing() /** @@ -417,7 +416,7 @@ interface PanacheMongoCompanionBase { * @see [list] */ @GenerateBridge - fun stream(query: Document): Stream = throw INSTANCE.implementationInjectionMissing() + fun stream(query: Bson): Stream = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, @@ -431,7 +430,7 @@ interface PanacheMongoCompanionBase { * @see [list] */ @GenerateBridge - fun stream(query: Document, sort: Document): Stream = + fun stream(query: Bson, sort: Bson): Stream = throw INSTANCE.implementationInjectionMissing() /** @@ -510,8 +509,7 @@ interface PanacheMongoCompanionBase { * @return the number of entities counted. * @see [count] */ - @GenerateBridge - fun count(query: Document): Long = throw INSTANCE.implementationInjectionMissing() + @GenerateBridge fun count(query: Bson): Long = throw INSTANCE.implementationInjectionMissing() /** * Delete all entities of this type from the database. @@ -568,8 +566,7 @@ interface PanacheMongoCompanionBase { * @see [deleteAll] * @see [delete] */ - @GenerateBridge - fun delete(query: Document): Long = throw INSTANCE.implementationInjectionMissing() + @GenerateBridge fun delete(query: Bson): Long = throw INSTANCE.implementationInjectionMissing() /** * Delete an entity of this type by ID. @@ -723,7 +720,7 @@ interface PanacheMongoCompanionBase { * @see [update] */ @GenerateBridge - fun update(update: Document): io.quarkus.mongodb.panache.common.PanacheUpdate = + fun update(update: Bson): io.quarkus.mongodb.panache.common.PanacheUpdate = throw INSTANCE.implementationInjectionMissing() /** diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt index 9e48d93c83329..c823ce77fa278 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/PanacheMongoRepositoryBase.kt @@ -9,7 +9,7 @@ import io.quarkus.panache.common.Parameters import io.quarkus.panache.common.Sort import io.quarkus.panache.common.impl.GenerateBridge import java.util.stream.Stream -import org.bson.Document +import org.bson.conversions.Bson /** * Represents a Repository for a specific type of entity [Entity], with an ID type of [Id]. @@ -144,26 +144,25 @@ interface PanacheMongoRepositoryBase { /** * Find entities using a BSON query. * - * @param query a [Document] query + * @param query a [Bson] query * @return a new [PanacheQuery] instance for the given query * @see [list] * @see [stream] */ @GenerateBridge - fun find(query: Document): PanacheQuery = - throw INSTANCE.implementationInjectionMissing() + fun find(query: Bson): PanacheQuery = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a new [PanacheQuery] instance for the given query * @see [list] * @see [stream] */ @GenerateBridge - fun find(query: Document, sort: Document): PanacheQuery = + fun find(query: Bson, sort: Bson): PanacheQuery = throw INSTANCE.implementationInjectionMissing() /** @@ -277,26 +276,26 @@ interface PanacheMongoRepositoryBase { /** * Find entities using a BSON query. This method is a shortcut for `find(query).list()`. * - * @param query a [Document] query + * @param query a [Bson] query * @return a [List] containing all results, without paging * @see [find] * @see [stream] */ @GenerateBridge - fun list(query: Document): List = throw INSTANCE.implementationInjectionMissing() + fun list(query: Bson): List = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).list()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [List] containing all results, without paging * @see [find] * @see [stream] */ @GenerateBridge - fun list(query: Document, sort: Document): List = + fun list(query: Bson, sort: Bson): List = throw INSTANCE.implementationInjectionMissing() /** @@ -410,26 +409,26 @@ interface PanacheMongoRepositoryBase { /** * Find entities using a BSON query. This method is a shortcut for `find(query).stream()`. * - * @param query a [Document] query + * @param query a [Bson] query * @return a [Stream] containing all results, without paging * @see [find] * @see [list] */ @GenerateBridge - fun stream(query: Document): Stream = throw INSTANCE.implementationInjectionMissing() + fun stream(query: Bson): Stream = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).stream()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [Stream] containing all results, without paging * @see [find] * @see [list] */ @GenerateBridge - fun stream(query: Document, sort: Document): Stream = + fun stream(query: Bson, sort: Bson): Stream = throw INSTANCE.implementationInjectionMissing() /** @@ -497,11 +496,10 @@ interface PanacheMongoRepositoryBase { /** * Counts the number of this type of entity matching the given query * - * @param query a [Document] query + * @param query a [Bson] query * @return the number of entities counted. */ - @GenerateBridge - fun count(query: Document): Long = throw INSTANCE.implementationInjectionMissing() + @GenerateBridge fun count(query: Bson): Long = throw INSTANCE.implementationInjectionMissing() /** * Delete all entities of this type from the database. @@ -559,11 +557,10 @@ interface PanacheMongoRepositoryBase { /** * Delete all entities of this type matching the given query * - * @param query a [Document] query + * @param query a [Bson] query * @return the number of entities counted. */ - @GenerateBridge - fun delete(query: Document): Long = throw INSTANCE.implementationInjectionMissing() + @GenerateBridge fun delete(query: Bson): Long = throw INSTANCE.implementationInjectionMissing() /** * Persist all given entities. @@ -695,7 +692,7 @@ interface PanacheMongoRepositoryBase { * document */ @GenerateBridge - fun update(update: Document): io.quarkus.mongodb.panache.common.PanacheUpdate = + fun update(update: Bson): io.quarkus.mongodb.panache.common.PanacheUpdate = throw INSTANCE.implementationInjectionMissing() /** Allow to access the underlying Mongo Collection */ diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt index a0f17492e0fe3..970c09b1370ad 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/ReactivePanacheMongoCompanion.kt @@ -9,7 +9,7 @@ import io.quarkus.panache.common.impl.GenerateBridge import io.smallrye.mutiny.Multi import io.smallrye.mutiny.Uni import java.util.stream.Stream -import org.bson.Document +import org.bson.conversions.Bson import org.bson.types.ObjectId /** @@ -138,7 +138,7 @@ interface ReactivePanacheMongoCompanionBase = + fun find(query: Bson): ReactivePanacheQuery = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a new [ReactivePanacheQuery] instance for the given query * @see [find] * @see [list] @@ -163,7 +163,7 @@ interface ReactivePanacheMongoCompanionBase = + fun find(query: Bson, sort: Bson): ReactivePanacheQuery = throw INSTANCE.implementationInjectionMissing() /** @@ -298,7 +298,7 @@ interface ReactivePanacheMongoCompanionBase> = throw INSTANCE.implementationInjectionMissing() + fun list(query: Bson): Uni> = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).list()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [List] containing all results, without paging * @see [find] * @see [find] @@ -323,7 +323,7 @@ interface ReactivePanacheMongoCompanionBase> = + fun list(query: Bson, sort: Bson): Uni> = throw INSTANCE.implementationInjectionMissing() /** @@ -458,7 +458,7 @@ interface ReactivePanacheMongoCompanionBase = throw INSTANCE.implementationInjectionMissing() + fun stream(query: Bson): Multi = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).stream()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [Multi] containing all results, without paging * @see [find] * @see [find] @@ -483,7 +483,7 @@ interface ReactivePanacheMongoCompanionBase = + fun stream(query: Bson, sort: Bson): Multi = throw INSTANCE.implementationInjectionMissing() /** @@ -565,14 +565,14 @@ interface ReactivePanacheMongoCompanionBase = throw INSTANCE.implementationInjectionMissing() + fun count(query: Bson): Uni = throw INSTANCE.implementationInjectionMissing() /** * Delete all entities of this type from the database. @@ -638,14 +638,14 @@ interface ReactivePanacheMongoCompanionBase = throw INSTANCE.implementationInjectionMissing() + fun delete(query: Bson): Uni = throw INSTANCE.implementationInjectionMissing() /** * Insert all given entities. @@ -810,7 +810,7 @@ interface ReactivePanacheMongoCompanionBase { /** * Find entities using a BSON query. * - * @param query a [Document] query + * @param query a [Bson] query * @return a new [ReactivePanacheQuery] instance for the given query * @see [list] * @see [stream] */ @GenerateBridge - fun find(query: Document): ReactivePanacheQuery = + fun find(query: Bson): ReactivePanacheQuery = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a new [ReactivePanacheQuery] instance for the given query * @see [list] * @see [stream] */ @GenerateBridge - fun find(query: Document, sort: Document): ReactivePanacheQuery = + fun find(query: Bson, sort: Bson): ReactivePanacheQuery = throw INSTANCE.implementationInjectionMissing() /** @@ -281,26 +281,26 @@ interface ReactivePanacheMongoRepositoryBase { /** * Find entities using a BSON query. This method is a shortcut for `find(query).list()`. * - * @param query a [Document] query + * @param query a [Bson] query * @return a [List] containing all results, without paging * @see [find] * @see [stream] */ @GenerateBridge - fun list(query: Document): Uni> = throw INSTANCE.implementationInjectionMissing() + fun list(query: Bson): Uni> = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).list()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [List] containing all results, without paging * @see [find] * @see [stream] */ @GenerateBridge - fun list(query: Document, sort: Document): Uni> = + fun list(query: Bson, sort: Bson): Uni> = throw INSTANCE.implementationInjectionMissing() /** @@ -415,26 +415,26 @@ interface ReactivePanacheMongoRepositoryBase { /** * Find entities using a BSON query. This method is a shortcut for `find(query).stream()`. * - * @param query a [Document] query + * @param query a [Bson] query * @return a [Multi] containing all results, without paging * @see [find] * @see [list] */ @GenerateBridge - fun stream(query: Document): Multi = throw INSTANCE.implementationInjectionMissing() + fun stream(query: Bson): Multi = throw INSTANCE.implementationInjectionMissing() /** * Find entities using a BSON query and a BSON sort. This method is a shortcut for `find(query, * sort).stream()`. * - * @param query a [Document] query - * @param sort the [Document] sort + * @param query a [Bson] query + * @param sort the [Bson] sort * @return a [Multi] containing all results, without paging * @see [find] * @see [list] */ @GenerateBridge - fun stream(query: Document, sort: Document): Multi = + fun stream(query: Bson, sort: Bson): Multi = throw INSTANCE.implementationInjectionMissing() /** @@ -501,11 +501,11 @@ interface ReactivePanacheMongoRepositoryBase { /** * Counts the number of this type of entity matching the given query * - * @param query a [Document] query + * @param query a [Bson] query * @return the number of entities counted. */ @GenerateBridge - fun count(query: Document): Uni = throw INSTANCE.implementationInjectionMissing() + fun count(query: Bson): Uni = throw INSTANCE.implementationInjectionMissing() /** * Delete all entities of this type from the database. @@ -563,11 +563,11 @@ interface ReactivePanacheMongoRepositoryBase { /** * Delete all entities of this type matching the given query * - * @param query a [Document] query + * @param query a [Bson] query * @return the number of entities counted. */ @GenerateBridge - fun delete(query: Document): Uni = throw INSTANCE.implementationInjectionMissing() + fun delete(query: Bson): Uni = throw INSTANCE.implementationInjectionMissing() /** * Persist all given entities. @@ -694,13 +694,13 @@ interface ReactivePanacheMongoRepositoryBase { * [io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate] object will allow to * restrict on which document the update should be applied. * - * @param update the update document, as a [Document]. + * @param update the update document, as a [Bson]. * @param params [Parameters] of named parameters * @return a new [io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate] instance for * the given update document */ @GenerateBridge - fun update(update: Document): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = + fun update(update: Bson): io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate = throw INSTANCE.implementationInjectionMissing() /** Allow to access the underlying Mongo Collection */ diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt index c908433a4c05c..35f8b25f32692 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/reactive/runtime/KotlinReactiveMongoOperations.kt @@ -7,7 +7,7 @@ import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheQuery import io.quarkus.mongodb.reactive.ReactiveMongoCollection import io.smallrye.mutiny.Multi import io.smallrye.mutiny.Uni -import org.bson.Document +import org.bson.conversions.Bson /** Defines kotlin specific implementations of methods needed by [ReactiveMongoOperations]. */ class KotlinReactiveMongoOperations : @@ -25,14 +25,11 @@ class KotlinReactiveMongoOperations : * * @param collection the collection to query * @param query the query to base the new query off of - * @param sortDoc the sort document to use + * @param sortDoc the sort Bson to use * @return the new query implementation */ - override fun createQuery( - collection: ReactiveMongoCollection<*>, - query: Document?, - sortDoc: Document? - ) = ReactivePanacheQueryImpl(collection, query, sortDoc) + override fun createQuery(collection: ReactiveMongoCollection<*>, query: Bson?, sortDoc: Bson?) = + ReactivePanacheQueryImpl(collection, query, sortDoc) /** * Creates the update implementation @@ -45,7 +42,7 @@ class KotlinReactiveMongoOperations : override fun createUpdate( collection: ReactiveMongoCollection<*>, entityClass: Class<*>, - docUpdate: Document + docUpdate: Bson ) = ReactivePanacheUpdateImpl(this, entityClass, docUpdate, collection) /** diff --git a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt index d5ae1e11e8e77..a03d10f2a0ecb 100644 --- a/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt +++ b/extensions/panache/mongodb-panache-kotlin/runtime/src/main/kotlin/io/quarkus/mongodb/panache/kotlin/runtime/KotlinMongoOperations.kt @@ -7,7 +7,7 @@ import io.quarkus.mongodb.panache.common.runtime.MongoOperations import io.quarkus.mongodb.panache.common.runtime.PanacheUpdateImpl import io.quarkus.mongodb.panache.kotlin.PanacheQuery import java.util.stream.Stream -import org.bson.Document +import org.bson.conversions.Bson /** Defines kotlin specific implementations of methods needed by [MongoOperations]. */ class KotlinMongoOperations : MongoOperations, PanacheUpdate>() { @@ -30,8 +30,8 @@ class KotlinMongoOperations : MongoOperations, PanacheUpdate>() override fun createQuery( collection: MongoCollection<*>, session: ClientSession?, - query: Document?, - sortDoc: Document? + query: Bson?, + sortDoc: Bson? ) = PanacheQueryImpl(collection, session, query, sortDoc) /** @@ -45,7 +45,7 @@ class KotlinMongoOperations : MongoOperations, PanacheUpdate>() override fun createUpdate( collection: MongoCollection<*>, entityClass: Class<*>, - docUpdate: Document + docUpdate: Bson ) = PanacheUpdateImpl(this, entityClass, docUpdate, collection) /** diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoEntityBase.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoEntityBase.java index 05b4269dcf41b..6df730c0a5702 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoEntityBase.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoEntityBase.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.stream.Stream; -import org.bson.Document; +import org.bson.conversions.Bson; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; @@ -202,33 +202,33 @@ public static PanacheQuery find(String que /** * Find entities using a BSON query. * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a new {@link PanacheQuery} instance for the given query - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static PanacheQuery find(Document query) { + public static PanacheQuery find(Bson query) { throw INSTANCE.implementationInjectionMissing(); } /** * Find entities using a BSON query and a BSON sort. * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a new {@link PanacheQuery} instance for the given query - * @see #find(Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static PanacheQuery find(Document query, Document sort) { + public static PanacheQuery find(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -374,16 +374,16 @@ public static List list(String query, Sort * Find entities using a BSON query. * This method is a shortcut for find(query).list(). * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static List list(Document query) { + public static List list(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -391,17 +391,17 @@ public static List list(Document query) { * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).list(). * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static List list(Document query, Document sort) { + public static List list(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -549,16 +549,16 @@ public static Stream stream(String query, * Find entities using a BSON query. * This method is a shortcut for find(query).stream(). * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a {@link Stream} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static Stream stream(Document query) { + public static Stream stream(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -566,17 +566,17 @@ public static Stream stream(Document query * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).stream(). * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a {@link Stream} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static Stream stream(Document query, Document sort) { + public static Stream stream(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -670,14 +670,14 @@ public static long count(String query, Parameters params) { /** * Counts the number of this type of entity matching the given query * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - public static long count(Document query) { + public static long count(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -753,14 +753,14 @@ public static long delete(String query, Parameters params) { /** * Delete all entities of this type matching the given query * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - public static long delete(Document query) { + public static long delete(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -892,7 +892,7 @@ public static void persistOrUpdate(Object firstEntity, Object... entities) { * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Map) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge public static io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Object... params) { @@ -910,7 +910,7 @@ public static io.quarkus.mongodb.panache.common.PanacheUpdate update(String upda * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) * */ @GenerateBridge @@ -929,7 +929,7 @@ public static io.quarkus.mongodb.panache.common.PanacheUpdate update(String upda * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Map) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge public static io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Parameters params) { @@ -941,14 +941,14 @@ public static io.quarkus.mongodb.panache.common.PanacheUpdate update(String upda * The returned {@link io.quarkus.mongodb.panache.common.PanacheUpdate} object will allow to restrict on which document the * update should be applied. * - * @param update the update document, as a {@link org.bson.Document}. + * @param update the update document, as a {@link org.bson.conversions.Bson}. * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Map) * @see #update(String, Parameters) */ @GenerateBridge - public static io.quarkus.mongodb.panache.common.PanacheUpdate update(Document update) { + public static io.quarkus.mongodb.panache.common.PanacheUpdate update(Bson update) { throw INSTANCE.implementationInjectionMissing(); } diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoRepositoryBase.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoRepositoryBase.java index 93e9ff8c6f5bc..4f03a53893a30 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoRepositoryBase.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheMongoRepositoryBase.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.stream.Stream; -import org.bson.Document; +import org.bson.conversions.Bson; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; @@ -210,33 +210,33 @@ default PanacheQuery find(String query, Sort sort, Parameters params) { /** * Find entities using a BSON query. * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a new {@link PanacheQuery} instance for the given query - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default PanacheQuery find(Document query) { + default PanacheQuery find(Bson query) { throw INSTANCE.implementationInjectionMissing(); } /** * Find entities using a BSON query and a BSON sort. * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a new {@link PanacheQuery} instance for the given query - * @see #find(Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default PanacheQuery find(Document query, Document sort) { + default PanacheQuery find(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -382,16 +382,16 @@ default List list(String query, Sort sort, Parameters params) { * Find entities using a BSON query. * This method is a shortcut for find(query).list(). * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default List list(Document query) { + default List list(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -399,17 +399,17 @@ default List list(Document query) { * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).list(). * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default List list(Document query, Document sort) { + default List list(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -557,16 +557,16 @@ default Stream stream(String query, Sort sort, Parameters params) { * Find entities using a BSON query. * This method is a shortcut for find(query).stream(). * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return a {@link Stream} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default Stream stream(Document query) { + default Stream stream(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -574,17 +574,17 @@ default Stream stream(Document query) { * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).stream(). * - * @param query a {@link org.bson.Document} query - * @param sort the {@link org.bson.Document} sort + * @param query a {@link org.bson.conversions.Bson} query + * @param sort the {@link org.bson.conversions.Bson} sort * @return a {@link Stream} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) */ @GenerateBridge - default Stream stream(Document query, Document sort) { + default Stream stream(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -677,14 +677,14 @@ default long count(String query, Parameters params) { /** * Counts the number of this type of entity matching the given query * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - default long count(Document query) { + default long count(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -760,14 +760,14 @@ default long delete(String query, Parameters params) { /** * Delete all entities of this type matching the given query * - * @param query a {@link org.bson.Document} query + * @param query a {@link org.bson.conversions.Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - default long delete(Document query) { + default long delete(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -890,7 +890,7 @@ default void persistOrUpdate(Entity firstEntity, @SuppressWarnings("unchecked") * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Map) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Object... params) { @@ -908,7 +908,7 @@ default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Ob * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Map params) { @@ -926,7 +926,7 @@ default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Ma * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Map) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Parameters params) { @@ -938,14 +938,14 @@ default io.quarkus.mongodb.panache.common.PanacheUpdate update(String update, Pa * The returned {@link io.quarkus.mongodb.panache.common.PanacheUpdate} object will allow to restrict on which document the * update should be applied. * - * @param update the update document, as a {@link org.bson.Document}. + * @param update the update document, as a {@link org.bson.conversions.Bson}. * @return a new {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instance for the given update document * @see #update(String, Object...) * @see #update(String, Map) * @see #update(String, Parameters) */ @GenerateBridge - default io.quarkus.mongodb.panache.common.PanacheUpdate update(Document update) { + default io.quarkus.mongodb.panache.common.PanacheUpdate update(Bson update) { throw INSTANCE.implementationInjectionMissing(); } diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheQuery.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheQuery.java index 288d3a841c945..fa708d163886f 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheQuery.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheQuery.java @@ -214,7 +214,7 @@ public interface PanacheQuery { * Executes this query for the current page and return a single result. * * @return the single result - * @throws PanacheQueryException if there is not exactly one result. + * @throws io.quarkus.panache.common.exception.PanacheQueryException if there is not exactly one result. * @see #firstResult() */ public T singleResult(); @@ -223,7 +223,7 @@ public interface PanacheQuery { * Executes this query for the current page and return a single result. * * @return if found, an optional containing the entity, else Optional.empty(). - * @throws PanacheQueryException if there is more than one result. + * @throws io.quarkus.panache.common.exception.PanacheQueryException if there is more than one result. * @see #firstResultOptional() */ public Optional singleResultOptional(); diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoEntityBase.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoEntityBase.java index 0b9311c671b8c..daab6f75395dd 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoEntityBase.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoEntityBase.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.stream.Stream; -import org.bson.Document; +import org.bson.conversions.Bson; import io.quarkus.mongodb.reactive.ReactiveMongoCollection; import io.quarkus.mongodb.reactive.ReactiveMongoDatabase; @@ -209,33 +209,33 @@ public static ReactivePanacheQuery /** * Find entities using a BSON query. * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a new {@link ReactivePanacheQuery} instance for the given query - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static ReactivePanacheQuery find(Document query) { + public static ReactivePanacheQuery find(Bson query) { throw INSTANCE.implementationInjectionMissing(); } /** * Find entities using a BSON query and a BSON sort. * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a new {@link ReactivePanacheQuery} instance for the given query - * @see #find(Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static ReactivePanacheQuery find(Document query, Document sort) { + public static ReactivePanacheQuery find(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -385,16 +385,16 @@ public static Uni> list(Strin * Find entities using a BSON query. * This method is a shortcut for find(query).list(). * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static Uni> list(Document query) { + public static Uni> list(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -402,17 +402,17 @@ public static Uni> list(Docum * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).list(). * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - public static Uni> list(Document query, Document sort) { + public static Uni> list(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -561,7 +561,7 @@ public static Multi stream(String * Find entities using a BSON query. * This method is a shortcut for find(query).stream(). * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a {@link Multi} containing all results, without paging * @see #find(String, Parameters) * @see #find(String, Sort, Map) @@ -570,7 +570,7 @@ public static Multi stream(String * @see #stream(String, Sort, Parameters) */ @GenerateBridge - public static Multi stream(Document query) { + public static Multi stream(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -578,8 +578,8 @@ public static Multi stream(Documen * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).stream(). * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a {@link Multi} containing all results, without paging * @see #find(String, Parameters) * @see #find(String, Sort, Map) @@ -588,7 +588,7 @@ public static Multi stream(Documen * @see #stream(String, Sort, Parameters) */ @GenerateBridge - public static Multi stream(Document query, Document sort) { + public static Multi stream(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -682,14 +682,14 @@ public static Uni count(String query, Parameters params) { /** * Counts the number of this type of entity matching the given query * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - public static Uni count(Document query) { + public static Uni count(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -765,14 +765,14 @@ public static Uni delete(String query, Parameters params) { /** * Delete all entities of this type matching the given query * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - public static Uni delete(Document query) { + public static Uni delete(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -905,7 +905,7 @@ public static Uni persistOrUpdate(Object firstEntity, Object... entities) * document * @see #update(String, Map) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(String update, Object... params) { @@ -924,7 +924,7 @@ public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate u * document * @see #update(String, Object...) * @see #update(String, Parameters) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(String update, @@ -944,7 +944,7 @@ public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate u * document * @see #update(String, Object...) * @see #update(String, Map) - * @see #update(Document) + * @see #update(Bson) */ @GenerateBridge public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(String update, Parameters params) { @@ -956,7 +956,7 @@ public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate u * The returned {@link io.quarkus.mongodb.panache.common.PanacheUpdate} object will allow to restrict on which document the * update should be applied. * - * @param update the update document, as a {@link org.bson.Document}. + * @param update the update document, as a {@link org.bson.conversions.Bson}. * @return a new {@link io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate} instance for the given update * document * @see #update(String, Object...) @@ -964,7 +964,7 @@ public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate u * @see #update(String, Parameters) */ @GenerateBridge - public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(Document update) { + public static io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(Bson update) { throw INSTANCE.implementationInjectionMissing(); } diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoRepositoryBase.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoRepositoryBase.java index d594a091fe173..b9b357e7aa80c 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoRepositoryBase.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheMongoRepositoryBase.java @@ -7,7 +7,7 @@ import java.util.Optional; import java.util.stream.Stream; -import org.bson.Document; +import org.bson.conversions.Bson; import io.quarkus.mongodb.reactive.ReactiveMongoCollection; import io.quarkus.mongodb.reactive.ReactiveMongoDatabase; @@ -211,33 +211,33 @@ default ReactivePanacheQuery find(String query, Sort sort, Parameters pa /** * Find entities using a BSON query. * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a new {@link ReactivePanacheQuery} instance for the given query - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default ReactivePanacheQuery find(Document query) { + default ReactivePanacheQuery find(Bson query) { throw INSTANCE.implementationInjectionMissing(); } /** * Find entities using a BSON query and a BSON sort. * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a new {@link ReactivePanacheQuery} instance for the given query - * @see #find(Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default ReactivePanacheQuery find(Document query, Document sort) { + default ReactivePanacheQuery find(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -383,16 +383,16 @@ default Uni> list(String query, Sort sort, Parameters params) { * Find entities using a BSON query. * This method is a shortcut for find(query).list(). * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default Uni> list(Document query) { + default Uni> list(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -400,17 +400,17 @@ default Uni> list(Document query) { * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).list(). * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a {@link List} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default Uni> list(Document query, Document sort) { + default Uni> list(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -558,17 +558,17 @@ default Multi stream(String query, Sort sort, Parameters params) { * Find entities using a BSON query. * This method is a shortcut for find(query).stream(). * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return a {@link Multi} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default Multi stream(Document query) { + default Multi stream(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -576,18 +576,18 @@ default Multi stream(Document query) { * Find entities using a BSON query and a BSON sort. * This method is a shortcut for find(query, sort).stream(). * - * @param query a {@link Document} query - * @param sort the {@link Document} sort + * @param query a {@link Bson} query + * @param sort the {@link Bson} sort * @return a {@link Multi} containing all results, without paging - * @see #find(Document) - * @see #find(Document, Document) - * @see #list(Document) - * @see #list(Document, Document) - * @see #stream(Document) - * @see #stream(Document, Document) + * @see #find(Bson) + * @see #find(Bson, Bson) + * @see #list(Bson) + * @see #list(Bson, Bson) + * @see #stream(Bson) + * @see #stream(Bson, Bson) */ @GenerateBridge - default Multi stream(Document query, Document sort) { + default Multi stream(Bson query, Bson sort) { throw INSTANCE.implementationInjectionMissing(); } @@ -680,14 +680,14 @@ default Uni count(String query, Parameters params) { /** * Counts the number of this type of entity matching the given query * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - default Uni count(Document query) { + default Uni count(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -763,14 +763,14 @@ default Uni delete(String query, Parameters params) { /** * Delete all entities of this type matching the given query * - * @param query a {@link Document} query + * @param query a {@link Bson} query * @return he number of entities counted. * @see #count() * @see #count(String, Object...) * @see #count(String, Map) */ @GenerateBridge - default Uni delete(Document query) { + default Uni delete(Bson query) { throw INSTANCE.implementationInjectionMissing(); } @@ -943,7 +943,7 @@ default io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update( * which document the * update should be applied. * - * @param update the update document, as a {@link org.bson.Document}. + * @param update the update document, as a {@link org.bson.conversions.Bson}. * @return a new {@link io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate} instance for the given update * document * @see #update(String, Object...) @@ -951,7 +951,7 @@ default io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update( * @see #update(String, Parameters) */ @GenerateBridge - default io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(Document update) { + default io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate update(Bson update) { throw INSTANCE.implementationInjectionMissing(); } diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/JavaReactiveMongoOperations.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/JavaReactiveMongoOperations.java index f1411c4f5f30a..473d7d10f1358 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/JavaReactiveMongoOperations.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/runtime/JavaReactiveMongoOperations.java @@ -2,7 +2,7 @@ import java.util.List; -import org.bson.Document; +import org.bson.conversions.Bson; import io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate; import io.quarkus.mongodb.panache.common.reactive.runtime.ReactiveMongoOperations; @@ -17,13 +17,13 @@ public class JavaReactiveMongoOperations extends ReactiveMongoOperations createQuery(ReactiveMongoCollection collection, Document query, Document sortDoc) { + protected ReactivePanacheQuery createQuery(ReactiveMongoCollection collection, Bson query, Bson sortDoc) { return new ReactivePanacheQueryImpl(collection, query, sortDoc); } @Override protected ReactivePanacheUpdate createUpdate(ReactiveMongoCollection collection, Class entityClass, - Document docUpdate) { + Bson docUpdate) { return new ReactivePanacheUpdateImpl(this, entityClass, docUpdate, collection); } diff --git a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/JavaMongoOperations.java b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/JavaMongoOperations.java index fef64ae6a0ef4..e799647ca90d7 100644 --- a/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/JavaMongoOperations.java +++ b/extensions/panache/mongodb-panache/runtime/src/main/java/io/quarkus/mongodb/panache/runtime/JavaMongoOperations.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.stream.Stream; -import org.bson.Document; +import org.bson.conversions.Bson; import com.mongodb.client.ClientSession; import com.mongodb.client.MongoCollection; @@ -20,12 +20,12 @@ public class JavaMongoOperations extends MongoOperations, Panach public static final JavaMongoOperations INSTANCE = new JavaMongoOperations(); @Override - protected PanacheQuery createQuery(MongoCollection collection, ClientSession session, Document query, Document sortDoc) { + protected PanacheQuery createQuery(MongoCollection collection, ClientSession session, Bson query, Bson sortDoc) { return new PanacheQueryImpl(collection, session, query, sortDoc); } @Override - protected PanacheUpdate createUpdate(MongoCollection collection, Class entityClass, Document docUpdate) { + protected PanacheUpdate createUpdate(MongoCollection collection, Class entityClass, Bson docUpdate) { return new PanacheUpdateImpl(this, entityClass, docUpdate, collection); }