From 36dee61a8abc8a01e9a78af6f73eb2408a20c828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Fri, 15 Oct 2021 18:25:49 +0200 Subject: [PATCH 1/2] Remove Hibernate with Panache deprecated classes --- .../arc/deployment/SplitPackageProcessor.java | 1 - .../orm/panache/ProjectedFieldName.java | 20 ------------------- .../runtime/CommonPanacheQueryImpl.java | 6 ------ .../java/io/quarkus/it/panache/DogDto.java | 2 +- 4 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/ProjectedFieldName.java diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java index 3e2bb3a37b39b..a08a5bb44bb0c 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java @@ -46,7 +46,6 @@ public boolean test(String packageName) { // Remove the elements from this list when the original issue is fixed // so that we can detect further issues. return packageName.startsWith("io.fabric8.kubernetes") - || packageName.equals("io.quarkus.hibernate.orm.panache") || packageName.equals("io.quarkus.mongodb.panache.reactive") || packageName.equals("io.quarkus.mongodb.panache"); } diff --git a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/ProjectedFieldName.java b/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/ProjectedFieldName.java deleted file mode 100644 index be7288169329f..0000000000000 --- a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/ProjectedFieldName.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.quarkus.hibernate.orm.panache; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Define a field's path for the SELECT statement when using a projection DTO. - * It supports the "dot" notation for fields in referenced entities: - * the name is composed of the property name for the relationship, followed by a dot ("."), followed by the name of the field. - * - * @deprecated use {@link io.quarkus.hibernate.orm.panache.common.ProjectedFieldName} instead. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -@Deprecated(forRemoval = true, since = "2.1.0.Final") -public @interface ProjectedFieldName { - String value(); -} diff --git a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java b/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java index b9a2e59df19a1..a68413ec23a02 100644 --- a/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java +++ b/extensions/panache/hibernate-orm-panache-common/runtime/src/main/java/io/quarkus/hibernate/orm/panache/common/runtime/CommonPanacheQueryImpl.java @@ -99,12 +99,6 @@ public CommonPanacheQueryImpl project(Class type) { throw new PanacheQueryException("The annotation ProjectedFieldName must have a non-empty value."); } parameterName = name; - } else if (parameter.isAnnotationPresent(io.quarkus.hibernate.orm.panache.ProjectedFieldName.class)) { - final String name = parameter.getAnnotation(io.quarkus.hibernate.orm.panache.ProjectedFieldName.class).value(); - if (name.isEmpty()) { - throw new PanacheQueryException("The annotation ProjectedFieldName must have a non-empty value."); - } - parameterName = name; } else if (!parameter.isNamePresent()) { throw new PanacheQueryException( "Your application must be built with parameter names, this should be the default if" + diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto.java index 6c506dc5d89ca..fb6e1d6809654 100644 --- a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto.java +++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/DogDto.java @@ -1,6 +1,6 @@ package io.quarkus.it.panache; -import io.quarkus.hibernate.orm.panache.ProjectedFieldName; +import io.quarkus.hibernate.orm.panache.common.ProjectedFieldName; import io.quarkus.runtime.annotations.RegisterForReflection; @RegisterForReflection From 0a943e958600643c5d03aa678c3dc3e10a78614d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mathieu?= Date: Tue, 19 Oct 2021 14:26:25 +0200 Subject: [PATCH 2/2] Remove MongoDB with Panache deprecated classes --- .../arc/deployment/SplitPackageProcessor.java | 4 +- .../BasePanacheMongoResourceProcessor.java | 32 ------------ .../quarkus/mongodb/panache/MongoEntity.java | 32 ------------ .../mongodb/panache/PanacheUpdate.java | 50 ------------------- .../mongodb/panache/ProjectionFor.java | 18 ------- .../mongodb/panache/common/PanacheUpdate.java | 2 +- .../reactive/ReactivePanacheUpdate.java | 2 +- .../runtime/ReactiveMongoOperations.java | 33 ++++-------- .../panache/common/runtime/BeanUtils.java | 35 ++++--------- .../common/runtime/MongoOperations.java | 43 ++++++---------- .../reactive/ReactivePanacheUpdate.java | 50 ------------------- .../common/runtime/MongoOperationsTest.java | 2 +- .../mongodb/panache/kotlin/deployment/Book.kt | 2 +- .../kotlin/deployment/StudentRepository.kt | 3 +- .../bug10812/Bug10812BookClient1Entity.java | 2 +- .../Bug10812BookClient1ReactiveEntity.java | 2 +- .../bug10812/Bug10812BookClient2Entity.java | 2 +- .../Bug10812BookClient2ReactiveEntity.java | 2 +- .../Bug10812BookDefaultClientNameEntity.java | 2 +- ...12BookDefaultClientNameReactiveEntity.java | 2 +- .../mongoentity/LegacyMongoEntityEntity.java | 9 ---- .../LegacyMongoEntityRepository.java | 9 ---- .../panache/mongoentity/MongoEntityTest.java | 9 ---- .../quarkus/it/mongodb/panache/book/Book.kt | 2 +- .../it/mongodb/panache/book/BookEntity.kt | 2 +- .../it/mongodb/panache/book/BookShortView.kt | 2 +- .../reactive/book/ReactiveBookEntity.kt | 2 +- .../quarkus/it/mongodb/panache/book/Book.java | 2 +- .../it/mongodb/panache/book/BookEntity.java | 2 +- .../panache/book/BookEntityResource.java | 6 --- .../panache/book/BookRepositoryResource.java | 6 --- .../panache/book/LegacyBookShortView.java | 39 --------------- .../reactive/book/ReactiveBookEntity.java | 2 +- .../transaction/TransactionPerson.java | 2 +- .../panache/MongodbPanacheResourceTest.java | 7 --- .../it/mongodb/rest/data/panache/Author.java | 2 +- .../it/mongodb/rest/data/panache/Book.java | 2 +- 37 files changed, 57 insertions(+), 368 deletions(-) delete mode 100644 extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/MongoEntity.java delete mode 100644 extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheUpdate.java delete mode 100644 extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/ProjectionFor.java delete mode 100644 extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheUpdate.java delete mode 100644 extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityEntity.java delete mode 100644 extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityRepository.java delete mode 100644 integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/LegacyBookShortView.java diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java index a08a5bb44bb0c..c6b4338b6aca2 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java @@ -45,9 +45,7 @@ public class SplitPackageProcessor { public boolean test(String packageName) { // Remove the elements from this list when the original issue is fixed // so that we can detect further issues. - return packageName.startsWith("io.fabric8.kubernetes") - || packageName.equals("io.quarkus.mongodb.panache.reactive") - || packageName.equals("io.quarkus.mongodb.panache"); + return packageName.startsWith("io.fabric8.kubernetes"); } }; 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 d08dddfac643a..f7a190cf0273b 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 @@ -49,8 +49,6 @@ import io.quarkus.jsonb.spi.JsonbSerializerBuildItem; import io.quarkus.mongodb.deployment.MongoClientNameBuildItem; import io.quarkus.mongodb.deployment.MongoUnremovableClientsBuildItem; -import io.quarkus.mongodb.panache.MongoEntity; -import io.quarkus.mongodb.panache.ProjectionFor; import io.quarkus.mongodb.panache.common.PanacheMongoRecorder; import io.quarkus.mongodb.panache.jackson.ObjectIdDeserializer; import io.quarkus.mongodb.panache.jackson.ObjectIdSerializer; @@ -70,10 +68,8 @@ public abstract class BasePanacheMongoResourceProcessor { public static final DotName BSON_IGNORE = createSimple(BsonIgnore.class.getName()); public static final DotName BSON_PROPERTY = createSimple(BsonProperty.class.getName()); public static final DotName MONGO_ENTITY = createSimple(io.quarkus.mongodb.panache.common.MongoEntity.class.getName()); - public static final DotName DEPRECATED_MONGO_ENTITY = createSimple(MongoEntity.class.getName()); public static final DotName OBJECT_ID = createSimple(ObjectId.class.getName()); public static final DotName PROJECTION_FOR = createSimple(io.quarkus.mongodb.panache.common.ProjectionFor.class.getName()); - public static final DotName DEPRECATED_PROJECTION_FOR = createSimple(ProjectionFor.class.getName()); @BuildStep public void buildImperative(CombinedIndexBuildItem index, @@ -225,27 +221,6 @@ protected void handleProjectionFor(CombinedIndexBuildItem index, transformers.produce(new BytecodeTransformerBuildItem(info.name().toString(), fieldEnhancer)); } - // Register for building the property mapping cache - propertyMappingClass - .produce(new PropertyMappingClassBuildStep(targetClass.name().toString(), - annotationInstance.target().asClass().name().toString())); - } - for (AnnotationInstance annotationInstance : index.getIndex().getAnnotations(DEPRECATED_PROJECTION_FOR)) { - Type targetClass = annotationInstance.value().asClass(); - ClassInfo target = index.getIndex().getClassByName(targetClass.name()); - Map classPropertyMapping = new HashMap<>(); - extractMappings(classPropertyMapping, target, index); - propertyMapping.put(targetClass.name(), classPropertyMapping); - } - for (AnnotationInstance annotationInstance : index.getIndex().getAnnotations(DEPRECATED_PROJECTION_FOR)) { - Type targetClass = annotationInstance.value().asClass(); - Map targetPropertyMapping = propertyMapping.get(targetClass.name()); - if (targetPropertyMapping != null && !targetPropertyMapping.isEmpty()) { - ClassInfo info = annotationInstance.target().asClass(); - ProjectionForEnhancer fieldEnhancer = new ProjectionForEnhancer(targetPropertyMapping); - transformers.produce(new BytecodeTransformerBuildItem(info.name().toString(), fieldEnhancer)); - } - // Register for building the property mapping cache propertyMappingClass .produce(new PropertyMappingClassBuildStep(targetClass.name().toString(), @@ -265,13 +240,6 @@ public void mongoClientNames(ApplicationArchivesBuildItem applicationArchivesBui values.add(clientName.asString()); } } - instances = indexView.getAnnotations(DEPRECATED_MONGO_ENTITY); - for (AnnotationInstance annotation : instances) { - AnnotationValue clientName = annotation.value("clientName"); - if ((clientName != null) && !clientName.asString().isEmpty()) { - values.add(clientName.asString()); - } - } for (String value : values) { // we don't want the qualifier @MongoClientName qualifier added // as these clients will only be looked up programmatically via name diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/MongoEntity.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/MongoEntity.java deleted file mode 100644 index ff0a222fa1a05..0000000000000 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/MongoEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.quarkus.mongodb.panache; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * This annotation can be used to specify some configuration of the mapping of an entity to MongoDB. - * - * @deprecated use {@link io.quarkus.mongodb.panache.common.MongoEntity} instead. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Deprecated(forRemoval = true, since = "2.1.0") -public @interface MongoEntity { - /** - * The name of the collection (if not set the name of the entity class will be used) - */ - String collection() default ""; - - /** - * The name of the database (if not set the default from the property - * quarkus.mongodb.database will be used). - */ - String database() default ""; - - /** - * The name of the MongoDB client (if not set the default client will be used). - */ - String clientName() default ""; -} diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheUpdate.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheUpdate.java deleted file mode 100644 index 4ffd4191d6dd4..0000000000000 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/PanacheUpdate.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.quarkus.mongodb.panache; - -import java.util.Map; - -import io.quarkus.panache.common.Parameters; - -/** - * Interface representing an update query. - * - * Use one of its methods to perform the update query. - * - * @deprecated use {@link io.quarkus.mongodb.panache.common.PanacheUpdate} instead. - */ -@Deprecated(forRemoval = true, since = "2.1.0") -public interface PanacheUpdate { - - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params params optional sequence of indexed parameters - * @return the number of entities updated. - */ - public long where(String query, Object... params); - - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params {@link Map} of named parameters - * @return the number of entities updated. - */ - public long where(String query, Map params); - - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params {@link Parameters} of named parameters - * @return the number of entities updated. - */ - public long where(String query, Parameters params); - - /** - * Execute an update on all documents with the update document. - * - * @return the number of entities updated. - */ - public long all(); -} diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/ProjectionFor.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/ProjectionFor.java deleted file mode 100644 index f51e84b674a82..0000000000000 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/ProjectionFor.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.quarkus.mongodb.panache; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @deprecated use {@link io.quarkus.mongodb.panache.common.ProjectionFor} instead. - */ -@Inherited -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Deprecated(forRemoval = true, since = "2.1.0") -public @interface ProjectionFor { - Class value(); -} 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 d7f0bde322e71..b454548434c2f 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 @@ -9,7 +9,7 @@ * * Use one of its methods to perform the update query. */ -public interface PanacheUpdate extends io.quarkus.mongodb.panache.PanacheUpdate { +public interface PanacheUpdate { /** * Execute the update query 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 2308442218493..ac5a88e1ad529 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 @@ -10,7 +10,7 @@ * * Use one of its methods to perform the update query. */ -public interface ReactivePanacheUpdate extends io.quarkus.mongodb.panache.reactive.ReactivePanacheUpdate { +public interface ReactivePanacheUpdate { /** * Execute the update query 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 dcbca4b763b2e..f3651fc6cd32e 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 @@ -27,9 +27,9 @@ import com.mongodb.client.model.ReplaceOptions; import com.mongodb.client.model.WriteModel; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.binder.NativeQueryBinder; import io.quarkus.mongodb.panache.binder.PanacheQlQueryBinder; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.reactive.ReactiveMongoClient; import io.quarkus.mongodb.reactive.ReactiveMongoCollection; import io.quarkus.mongodb.reactive.ReactiveMongoDatabase; @@ -214,13 +214,8 @@ public Uni delete(Object entity) { } public ReactiveMongoCollection mongoCollection(Class entityClass) { - MongoEntity legacyEntity = entityClass.getAnnotation(MongoEntity.class); - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity = entityClass - .getAnnotation(io.quarkus.mongodb.panache.common.MongoEntity.class); - ReactiveMongoDatabase database = mongoDatabase(legacyEntity, mongoEntity); - if (legacyEntity != null && !legacyEntity.collection().isEmpty()) { - return database.getCollection(legacyEntity.collection(), entityClass); - } + MongoEntity mongoEntity = entityClass.getAnnotation(MongoEntity.class); + ReactiveMongoDatabase database = mongoDatabase(mongoEntity); if (mongoEntity != null && !mongoEntity.collection().isEmpty()) { return database.getCollection(mongoEntity.collection(), entityClass); } @@ -228,10 +223,8 @@ public ReactiveMongoCollection mongoCollection(Class entityClass) { } public ReactiveMongoDatabase mongoDatabase(Class entityClass) { - MongoEntity legacyEntity = entityClass.getAnnotation(MongoEntity.class); - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity = entityClass - .getAnnotation(io.quarkus.mongodb.panache.common.MongoEntity.class); - return mongoDatabase(legacyEntity, mongoEntity); + MongoEntity mongoEntity = entityClass.getAnnotation(MongoEntity.class); + return mongoDatabase(mongoEntity); } // @@ -316,21 +309,17 @@ private ReactiveMongoCollection mongoCollection(Object entity) { return mongoCollection(entityClass); } - private ReactiveMongoDatabase mongoDatabase(MongoEntity legacyEntity, - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity) { - ReactiveMongoClient mongoClient = clientFromArc(legacyEntity, mongoEntity, ReactiveMongoClient.class, true); - if (legacyEntity != null && !legacyEntity.database().isEmpty()) { - return mongoClient.getDatabase(legacyEntity.database()); - } - String databaseName = getDefaultDatabaseName(legacyEntity, mongoEntity); + private ReactiveMongoDatabase mongoDatabase(MongoEntity mongoEntity) { + ReactiveMongoClient mongoClient = clientFromArc(mongoEntity, ReactiveMongoClient.class, true); + String databaseName = getDefaultDatabaseName(mongoEntity); return mongoClient.getDatabase(databaseName); } - private String getDefaultDatabaseName(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity mongoEntity) { - return defaultDatabaseName.computeIfAbsent(beanName(legacyEntity, mongoEntity), new Function() { + private String getDefaultDatabaseName(MongoEntity mongoEntity) { + return defaultDatabaseName.computeIfAbsent(beanName(mongoEntity), new Function() { @Override public String apply(String beanName) { - return getDatabaseName(legacyEntity, mongoEntity, beanName); + return getDatabaseName(mongoEntity, beanName); } }); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java index cb6180628783b..14f0e4560dc50 100644 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java +++ b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/common/runtime/BeanUtils.java @@ -7,7 +7,7 @@ import io.quarkus.arc.Arc; import io.quarkus.arc.InjectableBean; import io.quarkus.arc.InstanceHandle; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.runtime.MongoClientBeanUtil; import io.quarkus.mongodb.runtime.MongoClientConfig; import io.quarkus.mongodb.runtime.MongoClients; @@ -17,28 +17,24 @@ public final class BeanUtils { private BeanUtils() { } - public static String beanName(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity entity) { + public static String beanName(MongoEntity entity) { if (entity != null && !entity.clientName().isEmpty()) { return entity.clientName(); } - if (legacyEntity != null && !legacyEntity.clientName().isEmpty()) { - return legacyEntity.clientName(); - } return MongoClientBeanUtil.DEFAULT_MONGOCLIENT_NAME; } - public static T clientFromArc(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity entity, + public static T clientFromArc(MongoEntity entity, Class clientClass, boolean isReactive) { T mongoClient = Arc.container() - .instance(clientClass, MongoClientBeanUtil.clientLiteral(beanName(legacyEntity, entity), isReactive)) + .instance(clientClass, MongoClientBeanUtil.clientLiteral(beanName(entity), isReactive)) .get(); if (mongoClient != null) { return mongoClient; } - if ((entity == null || entity.clientName().isEmpty()) - && (legacyEntity == null || legacyEntity.clientName().isEmpty())) { + if ((entity == null || entity.clientName().isEmpty())) { // this case happens when there are multiple instances because they are all annotated with @Named for (InstanceHandle handle : Arc.container().select(clientClass).handles()) { InjectableBean bean = handle.getBean(); @@ -53,17 +49,13 @@ public static T clientFromArc(MongoEntity legacyEntity, io.quarkus.mongodb.p } } throw new IllegalStateException(String.format("Unable to find default %s bean", clientClass.getSimpleName())); - } else if (entity != null && !entity.clientName().isEmpty()) { - throw new IllegalStateException( - String.format("Unable to find %s bean for entity %s", clientClass.getSimpleName(), entity)); } else { throw new IllegalStateException( - String.format("Unable to find %s bean for entity %s", clientClass.getSimpleName(), legacyEntity)); + String.format("Unable to find %s bean for entity %s", clientClass.getSimpleName(), entity)); } } - public static String getDatabaseName(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity mongoEntity, - String clientBeanName) { + public static String getDatabaseName(MongoEntity mongoEntity, String clientBeanName) { MongoClients mongoClients = Arc.container().instance(MongoClients.class).get(); MongoClientConfig matchingMongoClientConfig = mongoClients.getMatchingMongoClientConfig(clientBeanName); if (matchingMongoClientConfig.database.isPresent()) { @@ -78,23 +70,14 @@ public static String getDatabaseName(MongoEntity legacyEntity, io.quarkus.mongod } } - if (legacyEntity == null && mongoEntity == null) { + if (mongoEntity == null) { throw new IllegalArgumentException( "The database property was not configured for the default Mongo Client (via 'quarkus.mongodb.database'"); } - if (legacyEntity != null && legacyEntity.clientName().isEmpty()) { + if (mongoEntity.clientName().isEmpty()) { throw new IllegalArgumentException("The database attribute was not set for the @MongoEntity annotation " + "and neither was the database property configured for the default Mongo Client (via 'quarkus.mongodb.database')"); } - if (mongoEntity != null && mongoEntity.clientName().isEmpty()) { - throw new IllegalArgumentException("The database attribute was not set for the @MongoEntity annotation " - + "and neither was the database property configured for the default Mongo Client (via 'quarkus.mongodb.database')"); - } - if (legacyEntity != null) { - throw new IllegalArgumentException(String.format( - "The database attribute was not set for the @MongoEntity annotation neither was the database property configured for the named Mongo Client (via 'quarkus.mongodb.%s.database')", - legacyEntity.clientName())); - } throw new IllegalArgumentException(String.format( "The database attribute was not set for the @MongoEntity annotation neither was the database property configured for the named Mongo Client (via 'quarkus.mongodb.%s.database')", mongoEntity.clientName())); 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 246dffeb34299..74e4ef4c60ce6 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 @@ -36,9 +36,9 @@ import io.quarkus.arc.Arc; import io.quarkus.arc.InstanceHandle; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.binder.NativeQueryBinder; import io.quarkus.mongodb.panache.binder.PanacheQlQueryBinder; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.panache.transaction.MongoTransactionException; import io.quarkus.panache.common.Parameters; import io.quarkus.panache.common.Sort; @@ -188,24 +188,17 @@ public void delete(Object entity) { } public MongoCollection mongoCollection(Class entityClass) { - MongoEntity legacyMongoEntity = entityClass.getAnnotation(MongoEntity.class); - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity = entityClass - .getAnnotation(io.quarkus.mongodb.panache.common.MongoEntity.class); - MongoDatabase database = mongoDatabase(legacyMongoEntity, mongoEntity); + MongoEntity mongoEntity = entityClass.getAnnotation(MongoEntity.class); + MongoDatabase database = mongoDatabase(mongoEntity); if (mongoEntity != null && !mongoEntity.collection().isEmpty()) { return database.getCollection(mongoEntity.collection(), entityClass); } - if (legacyMongoEntity != null && !legacyMongoEntity.collection().isEmpty()) { - return database.getCollection(legacyMongoEntity.collection(), entityClass); - } return database.getCollection(entityClass.getSimpleName(), entityClass); } public MongoDatabase mongoDatabase(Class entityClass) { - MongoEntity legacyMongoEntity = entityClass.getAnnotation(MongoEntity.class); - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity = entityClass - .getAnnotation(io.quarkus.mongodb.panache.common.MongoEntity.class); - return mongoDatabase(legacyMongoEntity, mongoEntity); + MongoEntity mongoEntity = entityClass.getAnnotation(MongoEntity.class); + return mongoDatabase(mongoEntity); } // @@ -328,9 +321,7 @@ ClientSession getSession(Object entity) { } ClientSession getSession(Class entityClass) { - MongoEntity legacyMongoEntity = entityClass.getAnnotation(MongoEntity.class); - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity = entityClass - .getAnnotation(io.quarkus.mongodb.panache.common.MongoEntity.class); + MongoEntity mongoEntity = entityClass.getAnnotation(MongoEntity.class); InstanceHandle instance = Arc.container() .instance(TransactionSynchronizationRegistry.class); if (instance.isAvailable()) { @@ -338,18 +329,17 @@ ClientSession getSession(Class entityClass) { if (registry.getTransactionStatus() == Status.STATUS_ACTIVE) { ClientSession clientSession = (ClientSession) registry.getResource(SESSION_KEY); if (clientSession == null) { - return registerClientSession(legacyMongoEntity, mongoEntity, registry); + return registerClientSession(mongoEntity, registry); } } } return null; } - private ClientSession registerClientSession(MongoEntity legacyMongoEntity, - io.quarkus.mongodb.panache.common.MongoEntity mongoEntity, + private ClientSession registerClientSession(MongoEntity mongoEntity, TransactionSynchronizationRegistry registry) { TransactionManager transactionManager = Arc.container().instance(TransactionManager.class).get(); - MongoClient client = BeanUtils.clientFromArc(legacyMongoEntity, mongoEntity, MongoClient.class, false); + MongoClient client = BeanUtils.clientFromArc(mongoEntity, MongoClient.class, false); ClientSession clientSession = client.startSession(); clientSession.startTransaction();//TODO add txoptions from annotation registry.putResource(SESSION_KEY, clientSession); @@ -387,24 +377,21 @@ private MongoCollection mongoCollection(Object entity) { return mongoCollection(entityClass); } - private MongoDatabase mongoDatabase(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity mongoEntity) { - MongoClient mongoClient = BeanUtils.clientFromArc(legacyEntity, mongoEntity, MongoClient.class, false); - if (legacyEntity != null && !legacyEntity.database().isEmpty()) { - return mongoClient.getDatabase(legacyEntity.database()); - } + private MongoDatabase mongoDatabase(MongoEntity mongoEntity) { + MongoClient mongoClient = BeanUtils.clientFromArc(mongoEntity, MongoClient.class, false); if (mongoEntity != null && !mongoEntity.database().isEmpty()) { return mongoClient.getDatabase(mongoEntity.database()); } - String databaseName = getDefaultDatabaseName(legacyEntity, mongoEntity); + String databaseName = getDefaultDatabaseName(mongoEntity); return mongoClient.getDatabase(databaseName); } - private String getDefaultDatabaseName(MongoEntity legacyEntity, io.quarkus.mongodb.panache.common.MongoEntity mongoEntity) { - return defaultDatabaseName.computeIfAbsent(BeanUtils.beanName(legacyEntity, mongoEntity), + private String getDefaultDatabaseName(MongoEntity mongoEntity) { + return defaultDatabaseName.computeIfAbsent(BeanUtils.beanName(mongoEntity), new Function() { @Override public String apply(String beanName) { - return BeanUtils.getDatabaseName(legacyEntity, mongoEntity, beanName); + return BeanUtils.getDatabaseName(mongoEntity, beanName); } }); } diff --git a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheUpdate.java b/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheUpdate.java deleted file mode 100644 index dad63d45117b9..0000000000000 --- a/extensions/panache/mongodb-panache-common/runtime/src/main/java/io/quarkus/mongodb/panache/reactive/ReactivePanacheUpdate.java +++ /dev/null @@ -1,50 +0,0 @@ -package io.quarkus.mongodb.panache.reactive; - -import java.util.Map; - -import io.quarkus.panache.common.Parameters; -import io.smallrye.mutiny.Uni; - -/** - * Interface representing an update query. - * - * Use one of its methods to perform the update query. - * - * @deprecated use {@link io.quarkus.mongodb.panache.common.reactive.ReactivePanacheUpdate} instead. - */ -@Deprecated(forRemoval = true, since = "2.1.0") -public interface ReactivePanacheUpdate { - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params params optional sequence of indexed parameters - * @return the number of entities updated. - */ - public Uni where(String query, Object... params); - - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params {@link Map} of named parameters - * @return the number of entities updated. - */ - public Uni where(String query, Map params); - - /** - * Execute the update query with the update document. - * - * @param query a {@link io.quarkus.mongodb.panache query string} - * @param params {@link Parameters} of named parameters - * @return the number of entities updated. - */ - public Uni where(String query, Parameters params); - - /** - * Execute an update on all documents with the update document. - * - * @return the number of entities updated. - */ - public Uni all(); -} 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 f542f5d71e742..1b84561ffdd26 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 @@ -23,7 +23,7 @@ import com.mongodb.client.ClientSession; import com.mongodb.client.MongoCollection; -import io.quarkus.mongodb.panache.PanacheUpdate; +import io.quarkus.mongodb.panache.common.PanacheUpdate; import io.quarkus.panache.common.Parameters; class MongoOperationsTest { diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/Book.kt b/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/Book.kt index 006431efe0d18..922b50930d8db 100644 --- a/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/Book.kt +++ b/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/Book.kt @@ -2,7 +2,7 @@ package io.quarkus.mongodb.panache.kotlin.deployment import com.mongodb.client.MongoCollection import com.mongodb.client.MongoDatabase -import io.quarkus.mongodb.panache.PanacheUpdate +import io.quarkus.mongodb.panache.common.PanacheUpdate import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanion import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity import io.quarkus.mongodb.panache.kotlin.PanacheQuery diff --git a/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/StudentRepository.kt b/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/StudentRepository.kt index f95847a96f430..868560dd488ce 100644 --- a/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/StudentRepository.kt +++ b/extensions/panache/mongodb-panache-kotlin/deployment/src/test/kotlin/io/quarkus/mongodb/panache/kotlin/deployment/StudentRepository.kt @@ -2,10 +2,9 @@ package io.quarkus.mongodb.panache.kotlin.deployment import com.mongodb.client.MongoCollection import com.mongodb.client.MongoDatabase -import io.quarkus.mongodb.panache.PanacheUpdate +import io.quarkus.mongodb.panache.common.PanacheUpdate import io.quarkus.mongodb.panache.kotlin.PanacheMongoRepositoryBase import io.quarkus.mongodb.panache.kotlin.PanacheQuery -import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE import io.quarkus.panache.common.Parameters import io.quarkus.panache.common.Sort diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1Entity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1Entity.java index e5b424184a886..f23c6d682c9d5 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1Entity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1Entity.java @@ -2,8 +2,8 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl1-10812") public class Bug10812BookClient1Entity extends PanacheMongoEntity { diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1ReactiveEntity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1ReactiveEntity.java index 1390bfb5f2226..f985be0d9fc0c 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1ReactiveEntity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient1ReactiveEntity.java @@ -2,7 +2,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl1-10812") diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2Entity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2Entity.java index 824116d05f095..0a12ea068f5c8 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2Entity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2Entity.java @@ -2,8 +2,8 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl2-10812") public class Bug10812BookClient2Entity extends PanacheMongoEntity { diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2ReactiveEntity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2ReactiveEntity.java index 1150b7f328b00..f53250ccb7a2a 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2ReactiveEntity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookClient2ReactiveEntity.java @@ -2,7 +2,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl2-10812") diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameEntity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameEntity.java index 0ab70295b7601..7162f82f64e09 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameEntity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameEntity.java @@ -2,8 +2,8 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(collection = "TheBookEntity") public class Bug10812BookDefaultClientNameEntity extends PanacheMongoEntity { diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameReactiveEntity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameReactiveEntity.java index 4779194277ae3..ff6b4a0fe392d 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameReactiveEntity.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/bug10812/Bug10812BookDefaultClientNameReactiveEntity.java @@ -2,7 +2,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity; @MongoEntity(collection = "TheBookEntity") diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityEntity.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityEntity.java deleted file mode 100644 index 76f1aef84be08..0000000000000 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityEntity.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.quarkus.mongodb.panache.mongoentity; - -import io.quarkus.mongodb.panache.MongoEntity; -import io.quarkus.mongodb.panache.PanacheMongoEntity; - -@MongoEntity(database = "legacyMongoEntity") -public class LegacyMongoEntityEntity extends PanacheMongoEntity { - public String field; -} diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityRepository.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityRepository.java deleted file mode 100644 index ed4b7fc00981e..0000000000000 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/LegacyMongoEntityRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.quarkus.mongodb.panache.mongoentity; - -import javax.enterprise.context.ApplicationScoped; - -import io.quarkus.mongodb.panache.PanacheMongoRepository; - -@ApplicationScoped -public class LegacyMongoEntityRepository implements PanacheMongoRepository { -} diff --git a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/MongoEntityTest.java b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/MongoEntityTest.java index 41bfeee701d0f..ce3690787c589 100644 --- a/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/MongoEntityTest.java +++ b/extensions/panache/mongodb-panache/deployment/src/test/java/io/quarkus/mongodb/panache/mongoentity/MongoEntityTest.java @@ -16,14 +16,10 @@ public class MongoEntityTest { static QuarkusUnitTest runner = new QuarkusUnitTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) .addClasses( - LegacyMongoEntityEntity.class, - LegacyMongoEntityRepository.class, MongoEntityEntity.class, MongoEntityRepository.class) .addAsResource("application.properties")); - @Inject - LegacyMongoEntityRepository legacyMongoEntityRepository; @Inject MongoEntityRepository mongoEntityRepository; @@ -33,9 +29,4 @@ public void testMongoEntity() { assertEquals("mongoEntity", mongoEntityRepository.mongoDatabase().getName()); } - @Test - public void testLegacyMongoEntity() { - assertEquals("legacyMongoEntity", LegacyMongoEntityEntity.mongoDatabase().getName()); - assertEquals("legacyMongoEntity", legacyMongoEntityRepository.mongoDatabase().getName()); - } } diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt index 63d54cd962df3..545e2dcb6cfde 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/Book.kt @@ -1,6 +1,6 @@ package io.quarkus.it.mongodb.panache.book -import io.quarkus.mongodb.panache.MongoEntity +import io.quarkus.mongodb.panache.common.MongoEntity import org.bson.codecs.pojo.annotations.BsonIgnore import org.bson.codecs.pojo.annotations.BsonProperty import org.bson.types.ObjectId diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt index 5b61afc594a48..2239ed1c99d98 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookEntity.kt @@ -1,6 +1,6 @@ package io.quarkus.it.mongodb.panache.book -import io.quarkus.mongodb.panache.MongoEntity +import io.quarkus.mongodb.panache.common.MongoEntity import io.quarkus.mongodb.panache.kotlin.PanacheMongoCompanion import io.quarkus.mongodb.panache.kotlin.PanacheMongoEntity import io.quarkus.mongodb.panache.kotlin.runtime.KotlinMongoOperations.Companion.INSTANCE diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt index fe12bfd04ed45..c2ec7bad1ab50 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/book/BookShortView.kt @@ -1,6 +1,6 @@ package io.quarkus.it.mongodb.panache.book -import io.quarkus.mongodb.panache.ProjectionFor +import io.quarkus.mongodb.panache.common.ProjectionFor import java.time.LocalDate import javax.json.bind.annotation.JsonbDateFormat diff --git a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt index 38ebce70fb33b..100fba8708385 100644 --- a/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt +++ b/integration-tests/mongodb-panache-kotlin/src/main/kotlin/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.kt @@ -1,7 +1,7 @@ package io.quarkus.it.mongodb.panache.reactive.book import io.quarkus.it.mongodb.panache.book.BookDetail -import io.quarkus.mongodb.panache.MongoEntity +import io.quarkus.mongodb.panache.common.MongoEntity import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoCompanion import io.quarkus.mongodb.panache.kotlin.reactive.ReactivePanacheMongoEntity import org.bson.codecs.pojo.annotations.BsonIgnore diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/Book.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/Book.java index e844d7bd03cef..4362e68746e37 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/Book.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/Book.java @@ -10,7 +10,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty; import org.bson.types.ObjectId; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(collection = "TheBook", clientName = "cl2") public class Book { diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntity.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntity.java index 774f0571455f7..d981b8d755ade 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntity.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntity.java @@ -9,8 +9,8 @@ import org.bson.codecs.pojo.annotations.BsonIgnore; import org.bson.codecs.pojo.annotations.BsonProperty; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl2") public class BookEntity extends PanacheMongoEntity { diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntityResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntityResource.java index 19b5482fdf4a2..f98d16594b2b9 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntityResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookEntityResource.java @@ -80,12 +80,6 @@ public List getBooksByAuthor(@PathParam("author") String author) return BookEntity.find("author", author).project(BookShortView.class).list(); } - @GET - @Path("/legacy-search/{author}") - public List getLegacyBooksByAuthor(@PathParam("author") String author) { - return BookEntity.find("author", author).project(LegacyBookShortView.class).list(); - } - @GET @Path("/search") public BookEntity search(@QueryParam("author") String author, @QueryParam("title") String title, diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.java index 9d1e052260140..a0dd6d7549231 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/BookRepositoryResource.java @@ -83,12 +83,6 @@ public List getBooksByAuthor(@PathParam("author") String author) return bookRepository.find("author", author).project(BookShortView.class).list(); } - @GET - @Path("/legacy-search/{author}") - public List getLegacyBooksByAuthor(@PathParam("author") String author) { - return bookRepository.find("author", author).project(LegacyBookShortView.class).list(); - } - @GET @Path("/search") public Book search(@QueryParam("author") String author, @QueryParam("title") String title, diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/LegacyBookShortView.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/LegacyBookShortView.java deleted file mode 100644 index c2d34c9848a94..0000000000000 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/book/LegacyBookShortView.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.quarkus.it.mongodb.panache.book; - -import java.time.LocalDate; - -import javax.json.bind.annotation.JsonbDateFormat; - -import io.quarkus.mongodb.panache.ProjectionFor; - -@ProjectionFor(Book.class) -public class LegacyBookShortView { - private String title; // uses the field name title and not the column name bookTitle - private String author; - @JsonbDateFormat("yyyy-MM-dd") - private LocalDate creationDate; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public LocalDate getCreationDate() { - return creationDate; - } - - public void setCreationDate(LocalDate creationDate) { - this.creationDate = creationDate; - } -} diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.java index da222f1f092a0..099b281c90740 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/reactive/book/ReactiveBookEntity.java @@ -10,7 +10,7 @@ import org.bson.codecs.pojo.annotations.BsonProperty; import io.quarkus.it.mongodb.panache.book.BookDetail; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity; @MongoEntity(collection = "TheBookEntity", clientName = "cl2") diff --git a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/transaction/TransactionPerson.java b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/transaction/TransactionPerson.java index 7d43d5c6bb9f1..91f86068f8663 100644 --- a/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/transaction/TransactionPerson.java +++ b/integration-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/transaction/TransactionPerson.java @@ -2,8 +2,8 @@ import org.bson.codecs.pojo.annotations.BsonId; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntityBase; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity(database = "transaction-person") public class TransactionPerson extends PanacheMongoEntityBase { diff --git a/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.java b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.java index 3c307dae68c57..95a4dabb8601e 100644 --- a/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.java +++ b/integration-tests/mongodb-panache/src/test/java/io/quarkus/it/mongodb/panache/MongodbPanacheResourceTest.java @@ -145,13 +145,6 @@ private void callBookEndpoint(String endpoint) { Assertions.assertNotNull(list.get(0).getTitle()); Assertions.assertNull(list.get(0).getDetails()); - // magic query find("author", author) - list = get(endpoint + "/legacy-search/Victor Hugo").as(LIST_OF_BOOK_TYPE_REF); - Assertions.assertEquals(2, list.size()); - // we have a projection (legacy annotation) so we should not have the details field but we should have the title thanks to @BsonProperty - Assertions.assertNotNull(list.get(0).getTitle()); - Assertions.assertNull(list.get(0).getDetails()); - // magic query find("{'author':?1,'title':?1}", author, title) BookDTO book = get(endpoint + "/search?author=Victor Hugo&title=Notre-Dame de Paris").as(BookDTO.class); Assertions.assertNotNull(book); diff --git a/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Author.java b/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Author.java index 7c8e71f6b9ae1..40f5bf916e7c3 100644 --- a/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Author.java +++ b/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Author.java @@ -4,8 +4,8 @@ import com.fasterxml.jackson.annotation.JsonFormat; -import io.quarkus.mongodb.panache.MongoEntity; import io.quarkus.mongodb.panache.PanacheMongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity public class Author extends PanacheMongoEntity { diff --git a/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Book.java b/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Book.java index 3792c7ccf02de..6852fa0540c70 100644 --- a/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Book.java +++ b/integration-tests/mongodb-rest-data-panache/src/main/java/io/quarkus/it/mongodb/rest/data/panache/Book.java @@ -2,7 +2,7 @@ import org.bson.codecs.pojo.annotations.BsonId; -import io.quarkus.mongodb.panache.MongoEntity; +import io.quarkus.mongodb.panache.common.MongoEntity; @MongoEntity public class Book {