From b94976dc9b3c2febe6a4baf364fb74b5982bb469 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Sun, 7 Jul 2024 15:41:24 -0300 Subject: [PATCH 1/7] Removing obsolete code, ancient modules and dropped features --- pom.xml | 3 + querydsl-libraries/pom.xml | 5 +- .../java/com/querydsl/core/FilterFactory.java | 2 +- .../querydsl/core/MatchingFiltersFactory.java | 88 +- .../com/querydsl/core/ProjectionsFactory.java | 12 +- .../com/querydsl/core/QuerydslModule.java | 4 - .../querydsl-hibernate-search/pom.xml | 186 ---- .../hibernate/search/AbstractSearchQuery.java | 172 ---- .../hibernate/search/SearchQuery.java | 48 - .../hibernate/search/SearchSerializer.java | 60 -- .../hibernate/search/package-info.java | 16 - .../hibernate/search/AbstractQueryTest.java | 91 -- .../com/querydsl/hibernate/search/QUser.java | 35 - .../hibernate/search/SearchQueryTest.java | 167 ---- .../search/SearchSerializerTest.java | 29 - .../com/querydsl/hibernate/search/User.java | 90 -- .../src/test/resources/derby.properties | 15 - querydsl-libraries/querydsl-lucene3/README.md | 59 -- querydsl-libraries/querydsl-lucene3/pom.xml | 92 -- .../querydsl/lucene3/AbstractLuceneQuery.java | 365 -------- .../IgnoreCaseUnsupportedException.java | 28 - .../querydsl/lucene3/LuceneExpressions.java | 71 -- .../java/com/querydsl/lucene3/LuceneOps.java | 38 - .../com/querydsl/lucene3/LuceneQuery.java | 54 -- .../querydsl/lucene3/LuceneSerializer.java | 542 ------------ .../com/querydsl/lucene3/PhraseElement.java | 31 - .../com/querydsl/lucene3/QueryElement.java | 32 - .../com/querydsl/lucene3/ResultIterator.java | 84 -- .../com/querydsl/lucene3/TermElement.java | 31 - .../java/com/querydsl/lucene3/TypedQuery.java | 52 -- .../com/querydsl/lucene3/package-info.java | 16 - .../com/querydsl/lucene3/LuceneQueryTest.java | 745 ---------------- .../LuceneSerializerNotTokenizedTest.java | 218 ----- .../lucene3/LuceneSerializerTest.java | 697 --------------- .../java/com/querydsl/lucene3/Person.java | 42 - .../querydsl/lucene3/PhraseElementTest.java | 51 -- .../java/com/querydsl/lucene3/QDocument.java | 35 - .../querydsl/lucene3/QueryElementTest.java | 35 - .../com/querydsl/lucene3/TermElementTest.java | 44 - .../test/resources/log4j.properties.example | 9 - querydsl-libraries/querydsl-lucene4/README.md | 57 -- querydsl-libraries/querydsl-lucene4/pom.xml | 104 --- .../querydsl/lucene4/AbstractLuceneQuery.java | 371 -------- .../IgnoreCaseUnsupportedException.java | 28 - .../querydsl/lucene4/LuceneExpressions.java | 73 -- .../java/com/querydsl/lucene4/LuceneOps.java | 38 - .../com/querydsl/lucene4/LuceneQuery.java | 54 -- .../querydsl/lucene4/LuceneSerializer.java | 553 ------------ .../com/querydsl/lucene4/PhraseElement.java | 31 - .../com/querydsl/lucene4/QueryElement.java | 32 - .../com/querydsl/lucene4/ResultIterator.java | 84 -- .../com/querydsl/lucene4/TermElement.java | 31 - .../java/com/querydsl/lucene4/TypedQuery.java | 52 -- .../com/querydsl/lucene4/package-info.java | 16 - .../com/querydsl/lucene4/LuceneQueryTest.java | 747 ---------------- .../LuceneSerializerNotTokenizedTest.java | 218 ----- .../lucene4/LuceneSerializerTest.java | 718 --------------- .../java/com/querydsl/lucene4/Person.java | 42 - .../querydsl/lucene4/PhraseElementTest.java | 51 -- .../java/com/querydsl/lucene4/QDocument.java | 35 - .../querydsl/lucene4/QueryElementTest.java | 35 - .../com/querydsl/lucene4/TermElementTest.java | 44 - .../test/resources/log4j.properties.example | 9 - querydsl-libraries/querydsl-lucene5/README.md | 57 -- querydsl-libraries/querydsl-lucene5/pom.xml | 104 --- .../querydsl/lucene5/AbstractLuceneQuery.java | 395 --------- .../IgnoreCaseUnsupportedException.java | 28 - .../querydsl/lucene5/LuceneExpressions.java | 73 -- .../java/com/querydsl/lucene5/LuceneOps.java | 38 - .../com/querydsl/lucene5/LuceneQuery.java | 53 -- .../querydsl/lucene5/LuceneSerializer.java | 580 ------------- .../com/querydsl/lucene5/PhraseElement.java | 31 - .../com/querydsl/lucene5/QueryElement.java | 32 - .../com/querydsl/lucene5/ResultIterator.java | 84 -- .../com/querydsl/lucene5/TermElement.java | 31 - .../java/com/querydsl/lucene5/TypedQuery.java | 52 -- .../com/querydsl/lucene5/package-info.java | 16 - .../com/querydsl/lucene5/LuceneQueryTest.java | 820 ------------------ .../LuceneSerializerNotTokenizedTest.java | 218 ----- .../lucene5/LuceneSerializerTest.java | 718 --------------- .../java/com/querydsl/lucene5/Person.java | 42 - .../querydsl/lucene5/PhraseElementTest.java | 51 -- .../java/com/querydsl/lucene5/QDocument.java | 35 - .../querydsl/lucene5/QueryElementTest.java | 35 - .../com/querydsl/lucene5/TermElementTest.java | 44 - .../test/resources/log4j.properties.example | 9 - .../r2dbc/R2DBCMatchingFiltersFactory.java | 88 +- querydsl-tooling/querydsl-apt/pom.xml | 29 - .../javax.annotation.processing.Processor | 1 - .../javax.annotation.processing.Processor | 1 - .../apt/jdo/JDOAnnotationProcessor.java | 48 - .../querydsl/apt/jdo/JDOConfiguration.java | 128 --- .../com/querydsl/apt/jdo/package-info.java | 16 - .../apt/roo/RooAnnotationProcessor.java | 55 -- .../com/querydsl/apt/roo/package-info.java | 16 - .../querydsl-apt/src/main/jdo.xml | 19 - .../querydsl-apt/src/main/roo.xml | 19 - .../apt/QuerydslAnnotationProcessorTest.java | 16 - .../java/com/querydsl/apt/domain/JDOTest.java | 67 +- .../apt/domain/QueryProjectionTest.java | 2 - .../apt/domain/QuerySuperTypeTest.java | 25 - .../com/querydsl/apt/domain/RooEntities.java | 29 - .../querydsl/apt/domain/RooEntitiesTest.java | 18 - .../java/com/querydsl/codegen/Keywords.java | 29 - .../querydsl/codegen/PropertyHandling.java | 15 - .../querydsl-maven-plugin/pom.xml | 5 - .../com/querydsl/maven/JDOExporterMojo.java | 42 - .../m2e/lifecycle-mapping-metadata.xml | 1 - .../test/java/com/querydsl/maven/Entity.java | 2 - .../querydsl/maven/JDOExporterMojoTest.java | 27 - 110 files changed, 87 insertions(+), 11974 deletions(-) delete mode 100644 querydsl-libraries/querydsl-hibernate-search/pom.xml delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/AbstractSearchQuery.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchQuery.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchSerializer.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/package-info.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/AbstractQueryTest.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/QUser.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchQueryTest.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchSerializerTest.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/User.java delete mode 100644 querydsl-libraries/querydsl-hibernate-search/src/test/resources/derby.properties delete mode 100644 querydsl-libraries/querydsl-lucene3/README.md delete mode 100644 querydsl-libraries/querydsl-lucene3/pom.xml delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/AbstractLuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/IgnoreCaseUnsupportedException.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneExpressions.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneOps.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneSerializer.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/PhraseElement.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/QueryElement.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/ResultIterator.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TermElement.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TypedQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/package-info.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneQueryTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerNotTokenizedTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/Person.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/PhraseElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QDocument.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QueryElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/TermElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene3/src/test/resources/log4j.properties.example delete mode 100644 querydsl-libraries/querydsl-lucene4/README.md delete mode 100644 querydsl-libraries/querydsl-lucene4/pom.xml delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/AbstractLuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/IgnoreCaseUnsupportedException.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneExpressions.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneOps.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneSerializer.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/PhraseElement.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/QueryElement.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/ResultIterator.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TermElement.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TypedQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/package-info.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneQueryTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerNotTokenizedTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/Person.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/PhraseElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QDocument.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QueryElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/TermElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene4/src/test/resources/log4j.properties.example delete mode 100644 querydsl-libraries/querydsl-lucene5/README.md delete mode 100644 querydsl-libraries/querydsl-lucene5/pom.xml delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/IgnoreCaseUnsupportedException.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneExpressions.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneOps.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/PhraseElement.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/QueryElement.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/ResultIterator.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TermElement.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TypedQuery.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/package-info.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneQueryTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerNotTokenizedTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/Person.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/PhraseElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QDocument.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QueryElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/TermElementTest.java delete mode 100644 querydsl-libraries/querydsl-lucene5/src/test/resources/log4j.properties.example delete mode 100644 querydsl-tooling/querydsl-apt/src/apt/jdo/META-INF/services/javax.annotation.processing.Processor delete mode 100644 querydsl-tooling/querydsl-apt/src/apt/roo/META-INF/services/javax.annotation.processing.Processor delete mode 100644 querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOAnnotationProcessor.java delete mode 100644 querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOConfiguration.java delete mode 100644 querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/package-info.java delete mode 100644 querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/RooAnnotationProcessor.java delete mode 100644 querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/package-info.java delete mode 100644 querydsl-tooling/querydsl-apt/src/main/jdo.xml delete mode 100644 querydsl-tooling/querydsl-apt/src/main/roo.xml delete mode 100644 querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QuerySuperTypeTest.java delete mode 100644 querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntities.java delete mode 100644 querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntitiesTest.java delete mode 100644 querydsl-tooling/querydsl-maven-plugin/src/main/java/com/querydsl/maven/JDOExporterMojo.java delete mode 100644 querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/JDOExporterMojoTest.java diff --git a/pom.xml b/pom.xml index 6d9b77b6c1..8966209db5 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,9 @@ + + true + false UTF-8 http://www.querydsl.com diff --git a/querydsl-libraries/pom.xml b/querydsl-libraries/pom.xml index 01c7a6c5d4..9fa800af9f 100644 --- a/querydsl-libraries/pom.xml +++ b/querydsl-libraries/pom.xml @@ -98,8 +98,6 @@ org.hibernate:hibernate-envers:*:*:compile org.hibernate.validator:hibernate-validator:*:*:compile org.eclipse.persistence:eclipselink:*:*:compile - org.datanucleus:javax.jdo:*:*:compile - org.springframework.roo:org.springframework.roo.annotations:*:*:compile org.mongodb.morphia:morphia:*:*:compile org.joda:joda-money:*:*:compile org.batoo.jpa:batoo-jpa:*:*:compile @@ -112,6 +110,9 @@ jakarta.xml.bind:jakarta.xml.bind-api:*:*:compile javax.*:*:*:*:* + + org.datanucleus:javax.jdo:*:*:* + org.springframework.roo:org.springframework.roo.annotations:*:*:compile org.hsqldb:hsqldb:*:*:compile com.h2database:h2:*:*:compile diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/FilterFactory.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/FilterFactory.java index b356711076..e52af3c415 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/FilterFactory.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/FilterFactory.java @@ -340,7 +340,7 @@ public Collection string( rv.add(expr.notBetween("A", "Z")); rv.add(expr.notBetween(other, other)); - if (!target.equals(Target.DERBY) && !module.equals(QuerydslModule.JDO)) { + if (!target.equals(Target.DERBY)) { // https://issues.apache.org/jira/browse/DERBY-4389 rv.add(new Coalesce<>(String.class, expr, other).getValue().eq("xxx")); } diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/MatchingFiltersFactory.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/MatchingFiltersFactory.java index b4a51274ca..3060a30e1c 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/MatchingFiltersFactory.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/MatchingFiltersFactory.java @@ -93,7 +93,6 @@ public Collection date( rv.add(expr.dayOfMonth().eq(other.dayOfMonth())); if (!target.equals(Target.DERBY) - && !module.equals(QuerydslModule.JDO) && !target.equals(Target.ORACLE) && !target.equals(Target.FIREBIRD) && (!target.equals(Target.POSTGRESQL) || !module.equals(QuerydslModule.JPA))) { @@ -134,7 +133,6 @@ public Collection dateTime( rv.add(expr.dayOfMonth().eq(other.dayOfMonth())); if (!target.equals(Target.DERBY) - && !module.equals(QuerydslModule.JDO) && !target.equals(Target.ORACLE) && (!target.equals(Target.POSTGRESQL) || !module.equals(QuerydslModule.JPA))) { rv.add(expr.dayOfWeek().eq(other.dayOfWeek())); @@ -210,12 +208,10 @@ public > Collection numeric( public Collection string(StringExpression expr, StringExpression other) { var rv = new HashSet(); - if (module != QuerydslModule.LUCENE) { - rv.addAll(comparable(expr, other)); + rv.addAll(comparable(expr, other)); - rv.add(expr.charAt(0).eq(other.charAt(0))); - rv.add(expr.charAt(1).eq(other.charAt(1))); - } + rv.add(expr.charAt(0).eq(other.charAt(0))); + rv.add(expr.charAt(1).eq(other.charAt(1))); rv.add(expr.contains(other)); rv.add(expr.contains(other.substring(0, 1))); @@ -244,58 +240,50 @@ public Collection string(StringExpression expr, StringExpression othe rv.add(expr.eq(other)); rv.add(expr.equalsIgnoreCase(other)); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.indexOf(other).eq(0)); - rv.add(expr.locate(other).eq(1)); - } + rv.add(expr.indexOf(other).eq(0)); + rv.add(expr.locate(other).eq(1)); - if (target != Target.DERBY && module != QuerydslModule.LUCENE) { + if (target != Target.DERBY) { rv.add(expr.indexOf(other.substring(1)).eq(1)); rv.add(expr.indexOf(other.substring(2)).eq(2)); } - if (module != QuerydslModule.LUCENE) { - rv.add(expr.isEmpty().not()); - rv.add(expr.isNotEmpty()); - } + rv.add(expr.isEmpty().not()); + rv.add(expr.isNotEmpty()); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.length().eq(other.length())); - rv.add(expr.like(other)); + rv.add(expr.length().eq(other.length())); + rv.add(expr.like(other)); - if (module != QuerydslModule.JDO || other instanceof Constant) { - rv.add(expr.like(other.substring(0, 1).append("%"))); - rv.add(expr.like(other.substring(0, 1).append("%").append(other.substring(2)))); - rv.add(expr.like(other.substring(1).prepend("%"))); - rv.add(expr.like(other.substring(1, 2).append("%").prepend("%"))); - } + if (other instanceof Constant) { + rv.add(expr.like(other.substring(0, 1).append("%"))); + rv.add(expr.like(other.substring(0, 1).append("%").append(other.substring(2)))); + rv.add(expr.like(other.substring(1).prepend("%"))); + rv.add(expr.like(other.substring(1, 2).append("%").prepend("%"))); } rv.add(expr.lower().eq(other.lower())); - if (module != QuerydslModule.LUCENE) { - if (!module.equals(QuerydslModule.SQL) - || (!target.equals(Target.HSQLDB) - && !target.equals(Target.FIREBIRD) - && !target.equals(Target.H2) - && !target.equals(Target.DB2) - && !target.equals(Target.DERBY) - && !target.equals(Target.SQLITE) - && !target.equals(Target.SQLSERVER))) { - - rv.add(expr.matches(other)); - - if (module != QuerydslModule.JDO || other instanceof Constant) { - rv.add(expr.matches(other.substring(0, 1).append(".*"))); - rv.add(expr.matches(other.substring(0, 1).append(".").append(other.substring(2)))); - rv.add(expr.matches(other.substring(1).prepend(".*"))); - rv.add(expr.matches(other.substring(1, 2).prepend(".*").append(".*"))); - } + if (!module.equals(QuerydslModule.SQL) + || (!target.equals(Target.HSQLDB) + && !target.equals(Target.FIREBIRD) + && !target.equals(Target.H2) + && !target.equals(Target.DB2) + && !target.equals(Target.DERBY) + && !target.equals(Target.SQLITE) + && !target.equals(Target.SQLSERVER))) { + + rv.add(expr.matches(other)); + + if (other instanceof Constant) { + rv.add(expr.matches(other.substring(0, 1).append(".*"))); + rv.add(expr.matches(other.substring(0, 1).append(".").append(other.substring(2)))); + rv.add(expr.matches(other.substring(1).prepend(".*"))); + rv.add(expr.matches(other.substring(1, 2).prepend(".*").append(".*"))); } - - rv.add(expr.ne(other)); } + rv.add(expr.ne(other)); + rv.add(expr.startsWith(other)); rv.add(expr.startsWith(other.substring(0, 1))); rv.add(expr.startsWith(other.substring(0, 2))); @@ -304,13 +292,11 @@ public Collection string(StringExpression expr, StringExpression othe rv.add(expr.startsWithIgnoreCase(other.substring(0, 1))); rv.add(expr.startsWithIgnoreCase(other.substring(0, 2))); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.substring(0, 1).eq(other.substring(0, 1))); - rv.add(expr.substring(1, 2).eq(other.substring(1, 2))); - rv.add(expr.substring(1).eq(other.substring(1))); + rv.add(expr.substring(0, 1).eq(other.substring(0, 1))); + rv.add(expr.substring(1, 2).eq(other.substring(1, 2))); + rv.add(expr.substring(1).eq(other.substring(1))); - rv.add(expr.trim().eq(other.trim())); - } + rv.add(expr.trim().eq(other.trim())); rv.add(expr.upper().eq(other.upper())); return Collections.unmodifiableSet(rv); diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ProjectionsFactory.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ProjectionsFactory.java index dd07b5408e..3345bf86f1 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ProjectionsFactory.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/ProjectionsFactory.java @@ -153,9 +153,7 @@ private > Collection> numer rv.add(expr.countDistinct()); } - if (!(other instanceof Constant - || module == QuerydslModule.JDO - || module == QuerydslModule.RDFBEAN)) { + if (!(other instanceof Constant || module == QuerydslModule.RDFBEAN)) { var cases = new CaseBuilder(); rv.add( NumberConstant.create(1) @@ -218,9 +216,7 @@ public Collection> stringProjections( rv.add(expr.substring(1)); rv.add(expr.substring(0, 1)); - if (!(other instanceof Constant - || module == QuerydslModule.JDO - || module == QuerydslModule.RDFBEAN)) { + if (!(other instanceof Constant || module == QuerydslModule.RDFBEAN)) { var cases = new CaseBuilder(); rv.add(cases.when(expr.eq("A")).then(other).when(expr.eq("B")).then(expr).otherwise(other)); @@ -231,9 +227,7 @@ public Collection> stringProjections( rv.add(expr.upper()); - if (module != QuerydslModule.JDO) { - rv.add(expr.nullif("xxx")); - } + rv.add(expr.nullif("xxx")); return Collections.unmodifiableSet(rv); } diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/QuerydslModule.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/QuerydslModule.java index 30cf177219..9b060f4870 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/QuerydslModule.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/QuerydslModule.java @@ -22,11 +22,7 @@ public enum QuerydslModule { /** */ JPA, /** */ - JDO, - /** */ RDFBEAN, /** */ SQL, - /** */ - LUCENE; } diff --git a/querydsl-libraries/querydsl-hibernate-search/pom.xml b/querydsl-libraries/querydsl-hibernate-search/pom.xml deleted file mode 100644 index 981ef7dc0c..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/pom.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - 4.0.0 - - - io.github.openfeign.querydsl - querydsl-libraries - 6.0-SNAPSHOT - - - querydsl-hibernate-search - Querydsl - Hibernate Search support - Hibernate Search support for querydsl - - - 6.3.1.Final - 8.0.1.Final - 6.2.2.Final - 5.5.5 - org.apache.lucene.*;version="[3.6,4)", - org.hibernate.*;version="[4,5)", - ${osgi.import.package.root} - - - - - - org.apache.lucene - lucene-core - ${lucene.version} - - - org.hibernate.common - hibernate-commons-annotations - 6.0.6.Final - - - - - - - io.github.openfeign.querydsl - querydsl-lucene5 - ${project.version} - - - - - org.hibernate.orm - hibernate-core - ${hibernate.version} - provided - - - asm - asm - - - org.jboss.logging - jboss-logging - - - - - org.hibernate.validator - hibernate-validator - ${hibernate.validator.version} - provided - - - org.jboss.logging - jboss-logging - - - - - - jakarta.persistence - jakarta.persistence-api - 3.1.0 - provided - - - - org.apache.lucene - lucene-core - ${lucene.version} - provided - - - org.hibernate.search - hibernate-search-mapper-orm-orm6 - ${hibernate.search.version} - provided - - - hsqldb - hsqldb - - - org.hibernate.orm - hibernate-core - - - org.slf4j - slf4j-api - - - - - javassist - javassist - 3.12.1.GA - provided - - - - - org.apache.derby - derby - ${derby.version} - test - - - org.apache.derby - derbytools - ${derby.version} - test - - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - test-jar - test - - - - javax.xml.bind - jaxb-api - 2.3.1 - test - - - - jakarta.validation - jakarta.validation-api - test - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - com.querydsl.hibernate.search - - - - - - org.apache.felix - maven-bundle-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - - derby.stream.error.file - target/derby.log - - - - - - - - diff --git a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/AbstractSearchQuery.java b/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/AbstractSearchQuery.java deleted file mode 100644 index 4c5edc8ad7..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/AbstractSearchQuery.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.querydsl.core.Fetchable; -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.SimpleQuery; -import com.querydsl.core.support.QueryMixin; -import com.querydsl.core.types.EntityPath; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.ParamExpression; -import com.querydsl.core.types.Predicate; -import com.querydsl.lucene5.LuceneSerializer; -import java.util.List; -import org.hibernate.Session; -import org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory; -import org.hibernate.search.engine.search.query.SearchQuery; -import org.hibernate.search.engine.search.query.dsl.SearchQueryOptionsStep; -import org.hibernate.search.mapper.orm.Search; -import org.hibernate.search.mapper.orm.search.loading.dsl.SearchLoadingOptionsStep; -import org.hibernate.search.mapper.orm.session.SearchSession; - -/** - * Abstract base class for Hibernate Search query classes - * - * @param result type - * @param concrete subtype - */ -public abstract class AbstractSearchQuery> - implements SimpleQuery, Fetchable { - - private final EntityPath path; - - private final QueryMixin queryMixin; - - private final LuceneSerializer serializer; - - private final SearchSession session; - - @SuppressWarnings("unchecked") - public AbstractSearchQuery(SearchSession session, EntityPath path) { - this.queryMixin = new QueryMixin((Q) this); - this.session = session; - this.path = path; - this.serializer = SearchSerializer.DEFAULT; - queryMixin.from(path); - } - - public AbstractSearchQuery(Session session, EntityPath path) { - this(Search.session(session), path); - } - - @Override - public long fetchCount() { - return createQuery(true).fetchTotalHitCount(); - } - - private SearchQuery createQuery(boolean forCount) { - QueryMetadata metadata = queryMixin.getMetadata(); - Class type = (Class) path.getType(); - // org.apache.lucene.search.Query query; - // if (metadata.getWhere() != null) { - // query = serializer.toQuery(metadata.getWhere(), metadata); - // } else { - // query = new MatchAllDocsQuery(); - // } - - // TODO: implement where clause - - SearchQueryOptionsStep queryStep = - session.search(type).where(SearchPredicateFactory::matchAll); - - // TODO: add sorting - // List> orderBy = metadata.getOrderBy(); - // if (!orderBy.isEmpty() && !forCount) { - // fullTextQuery.setSort(serializer.toSort(metadata.getOrderBy())); - // } - return queryStep.toQuery(); - } - - @Override - public Q distinct() { - return queryMixin.distinct(); - } - - @Override - @SuppressWarnings("unchecked") - public CloseableIterator iterate() { - return new IteratorAdapter(fetchAll(createQuery(false)).iterator()); - } - - @Override - public Q limit(long limit) { - return queryMixin.limit(limit); - } - - @SuppressWarnings("unchecked") - @Override - public List fetch() { - return fetchAll(createQuery(false)); - } - - @SuppressWarnings("unchecked") - @Override - public QueryResults fetchResults() { - SearchQuery query = createQuery(false); - return new QueryResults( - fetchAll(query), queryMixin.getMetadata().getModifiers(), query.fetchTotalHitCount()); - } - - private List fetchAll(SearchQuery query) { - return query.fetchHits( - queryMixin.getMetadata().getModifiers().getOffsetAsInteger(), - queryMixin.getMetadata().getModifiers().getLimitAsInteger()); - } - - @Override - public Q offset(long offset) { - return queryMixin.offset(offset); - } - - @Override - public Q orderBy(OrderSpecifier... o) { - return queryMixin.orderBy(o); - } - - @Override - public Q restrict(QueryModifiers modifiers) { - return queryMixin.restrict(modifiers); - } - - @Override - public

Q set(ParamExpression

param, P value) { - return queryMixin.set(param, value); - } - - @Override - public T fetchFirst() { - return limit(1).fetchFirst(); - } - - @SuppressWarnings("unchecked") - @Override - public T fetchOne() throws NonUniqueResultException { - try { - return (T) createQuery(false).fetchSingleHit(); - } catch (org.hibernate.NonUniqueResultException e) { - throw new NonUniqueResultException(e); - } - } - - @Override - public Q where(Predicate... e) { - return queryMixin.where(e); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchQuery.java b/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchQuery.java deleted file mode 100644 index 6f17ebf3f2..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchQuery.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import com.querydsl.core.types.EntityPath; -import org.hibernate.Session; -import org.hibernate.search.mapper.orm.Search; -import org.hibernate.search.mapper.orm.session.SearchSession; - -/** - * {@code SearchQuery} is a Query implementation for Hibernate Search - * - * @author tiwe - * @param - */ -public class SearchQuery extends AbstractSearchQuery> { - - /** - * Create a new SearchQuery instance - * - * @param session session - * @param path query source - */ - public SearchQuery(SearchSession session, EntityPath path) { - super(session, path); - } - - /** - * Create a new SearchQuery instance - * - * @param session session - * @param path query source - */ - public SearchQuery(Session session, EntityPath path) { - this(Search.session(session), path); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchSerializer.java b/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchSerializer.java deleted file mode 100644 index a8cf5539f5..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/SearchSerializer.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import com.querydsl.core.types.Path; -import com.querydsl.lucene5.LuceneSerializer; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; - -/** - * {@code SearchSerializer} extends the {@link LuceneSerializer} to use {@link FullTextField} - * annotation data from paths - * - * @author tiwe - */ -public class SearchSerializer extends LuceneSerializer { - - public static final SearchSerializer DEFAULT = new SearchSerializer(false, true); - - /** - * Create a new SearchSerializer instance - * - * @param lowerCase lowercase names - * @param splitTerms split terms - */ - public SearchSerializer(boolean lowerCase, boolean splitTerms) { - super(lowerCase, splitTerms); - } - - @Override - public String toField(Path path) { - if (path.getAnnotatedElement() != null) { - FullTextField fullTextField = path.getAnnotatedElement().getAnnotation(FullTextField.class); - if (fullTextField != null && fullTextField.name().length() > 0) { - return fullTextField.name(); - } - KeywordField keywordField = path.getAnnotatedElement().getAnnotation(KeywordField.class); - if (keywordField != null && keywordField.name().length() > 0) { - return keywordField.name(); - } - GenericField genericField = path.getAnnotatedElement().getAnnotation(GenericField.class); - if (genericField != null && genericField.name().length() > 0) { - return genericField.name(); - } - } - return super.toField(path); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/package-info.java b/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/package-info.java deleted file mode 100644 index 3d00e239e7..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/main/java/com/querydsl/hibernate/search/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Hibernate Search support */ -package com.querydsl.hibernate.search; diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/AbstractQueryTest.java b/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/AbstractQueryTest.java deleted file mode 100644 index 063371f552..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/AbstractQueryTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import com.querydsl.core.util.FileUtils; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.sql.SQLException; -import java.util.List; -import java.util.Properties; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.resource.transaction.spi.TransactionStatus; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; - -public abstract class AbstractQueryTest { - - private static SessionFactory sessionFactory; - - @BeforeClass - public static void setUpClass() throws IOException { - FileUtils.delete(new File("target/derbydb")); - FileUtils.delete(new File("target/lucene3")); - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass(User.class); - Properties props = new Properties(); - try (InputStream is = SearchQueryTest.class.getResourceAsStream("/derby.properties")) { - props.load(is); - } - cfg.setProperties(props); - sessionFactory = cfg.buildSessionFactory(); - } - - @AfterClass - public static void tearDownClass() { - if (sessionFactory != null) { - sessionFactory.close(); - } - } - - private Session session; - - protected Session getSession() { - return session; - } - - @SuppressWarnings("unchecked") - @Before - public void setUp() { - session = sessionFactory.openSession(); - session.beginTransaction(); - - // clean up - List users = session.createQuery("from User").list(); - for (User user : users) { - session.delete(user); - } - session.flush(); - } - - @After - public void tearDown() throws HibernateException, SQLException { - if (session - .getTransaction() - .getStatus() - .isNotOneOf( - TransactionStatus.ROLLED_BACK, - TransactionStatus.ROLLING_BACK, - TransactionStatus.MARKED_ROLLBACK)) { - session.getTransaction().commit(); - } - session.close(); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/QUser.java b/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/QUser.java deleted file mode 100644 index ed454309ad..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/QUser.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import com.querydsl.core.types.PathMetadataFactory; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.StringPath; - -public class QUser extends EntityPathBase { - - private static final long serialVersionUID = 8362025864799201294L; - - public QUser(String variable) { - super(User.class, PathMetadataFactory.forVariable(variable)); - } - - public final StringPath emailAddress = createString("emailAddress"); - - public final StringPath firstName = createString("firstName"); - - public final StringPath lastName = createString("lastName"); - - public final StringPath middleName = createString("middleName"); -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchQueryTest.java b/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchQueryTest.java deleted file mode 100644 index acb5a1b7d9..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchQueryTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryResults; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.dsl.BooleanExpression; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.hibernate.Session; -import org.junit.Ignore; -import org.junit.Test; - -public class SearchQueryTest extends AbstractQueryTest { - - private final QUser user = new QUser("user"); - - @Override - public void setUp() { - super.setUp(); - createUser("Bob", "Stewart", "Smith", "bob@example.com"); - - createUser("Barbara", "X", "Lock", "barbara@a.com"); - createUser("Anton", "X", "Bruckner", "anton@b.com"); - createUser("Robert", "X", "Downing", "bob@c.com"); - createUser("John", "X", "Stewart", "john@d.com"); - - Session session = getSession(); - session.flush(); - session.getTransaction().commit(); - session.beginTransaction(); - } - - @Test - public void exists() { - assertThat(query().where(user.emailAddress.eq("bob@example.com")).fetchCount() > 0).isTrue(); - assertThat(query().where(user.emailAddress.eq("bobby@example.com")).fetchCount() > 0).isFalse(); - } - - @Test - public void notExists() { - assertThat(query().where(user.emailAddress.eq("bob@example.com")).fetchCount() == 0).isFalse(); - assertThat(query().where(user.emailAddress.eq("bobby@example.com")).fetchCount() == 0).isTrue(); - } - - @Test - public void count() { - BooleanExpression filter = user.emailAddress.eq("bob@example.com"); - assertThat(query().where(filter).fetchCount()).isEqualTo(1); - } - - @Test - public void uniqueResult() { - BooleanExpression filter = user.emailAddress.eq("bob@example.com"); - User u = query().where(filter).fetchOne(); - assertThat(u).isNotNull(); - assertThat(u.getEmailAddress()).isEqualTo("bob@example.com"); - } - - @Test - public void list() { - BooleanExpression filter = user.emailAddress.eq("bob@example.com"); - List list = query().where(filter).fetch(); - assertThat(list).hasSize(1); - User u = query().where(filter).fetchOne(); - assertThat(list.getFirst()).isEqualTo(u); - } - - @Test(expected = NonUniqueResultException.class) - public void unique_result_throws_exception_on_multiple_results() { - query().where(user.middleName.eq("X")).fetchOne(); - } - - @Test - public void singleResult() { - assertThat(query().where(user.middleName.eq("X")).fetchFirst()).isNotNull(); - } - - @Test - public void ordering() { - BooleanExpression filter = user.middleName.eq("X"); - // asc - List asc = getFirstNames(query().where(filter).orderBy(user.firstName.asc()).fetch()); - assertThat(asc).isEqualTo(Arrays.asList("Anton", "Barbara", "John", "Robert")); - - // desc - List desc = getFirstNames(query().where(filter).orderBy(user.firstName.desc()).fetch()); - assertThat(desc).isEqualTo(Arrays.asList("Robert", "John", "Barbara", "Anton")); - } - - @Test - public void paging() { - BooleanExpression filter = user.middleName.eq("X"); - OrderSpecifier order = user.firstName.asc(); - - // limit - List limit = getFirstNames(query().where(filter).orderBy(order).limit(2).fetch()); - assertThat(limit).isEqualTo(Arrays.asList("Anton", "Barbara")); - - // offset - List offset = getFirstNames(query().where(filter).orderBy(order).offset(1).fetch()); - assertThat(offset).isEqualTo(Arrays.asList("Barbara", "John", "Robert")); - - // limit + offset - List limitAndOffset = - getFirstNames(query().where(filter).orderBy(order).limit(2).offset(1).fetch()); - assertThat(limitAndOffset).isEqualTo(Arrays.asList("Barbara", "John")); - } - - @Test - public void listResults() { - BooleanExpression filter = user.middleName.eq("X"); - QueryResults users = - query().where(filter).orderBy(user.firstName.asc()).limit(2).fetchResults(); - List asc = getFirstNames(users.getResults()); - assertThat(asc).isEqualTo(Arrays.asList("Anton", "Barbara")); - assertThat(users.getTotal()).isEqualTo(4); - } - - @Test - public void no_where() { - assertThat(query().fetch()).hasSize(5); - } - - @Test - @Ignore // OufOfMemoryError - public void limit_max_value() { - assertThat(query().limit(Long.MAX_VALUE).fetch()).hasSize(5); - } - - private List getFirstNames(List users) { - List rv = new ArrayList(users.size()); - for (User user : users) { - rv.add(user.getFirstName()); - } - return rv; - } - - private User createUser(String firstName, String middleName, String lastName, String email) { - User user = new User(); - user.setFirstName(firstName); - user.setMiddleName(middleName); - user.setLastName(lastName); - user.setEmailAddress(email); - getSession().save(user); - return user; - } - - private SearchQuery query() { - return new SearchQuery(getSession(), user); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchSerializerTest.java b/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchSerializerTest.java deleted file mode 100644 index 6c2db1097c..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/SearchSerializerTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class SearchSerializerTest { - - @Test - public void toField() { - SearchSerializer serializer = SearchSerializer.DEFAULT; - QUser user = new QUser("user"); - assertThat(serializer.toField(user.emailAddress)).isEqualTo("email"); - assertThat(serializer.toField(user.firstName)).isEqualTo("firstName"); - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/User.java b/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/User.java deleted file mode 100644 index 33497b092e..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/java/com/querydsl/hibernate/search/User.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.hibernate.search; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import java.io.Serializable; -import org.hibernate.annotations.NaturalId; -import org.hibernate.search.engine.backend.types.Projectable; -import org.hibernate.search.engine.backend.types.Searchable; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.DocumentId; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; - -@Entity -@Table(name = "user_") -@Indexed -public class User implements Serializable { - - private static final long serialVersionUID = 5955148455600241741L; - - @Id @GeneratedValue @DocumentId private Long id; - - // @SortableField - @GenericField(searchable = Searchable.YES, projectable = Projectable.YES) - private String firstName; - - @GenericField(searchable = Searchable.YES, projectable = Projectable.YES) - private String lastName; - - @GenericField(searchable = Searchable.YES, projectable = Projectable.YES) - private String middleName; - - @NaturalId - @GenericField(searchable = Searchable.YES, name = "email", projectable = Projectable.YES) - private String emailAddress; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getEmailAddress() { - return emailAddress; - } - - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } -} diff --git a/querydsl-libraries/querydsl-hibernate-search/src/test/resources/derby.properties b/querydsl-libraries/querydsl-hibernate-search/src/test/resources/derby.properties deleted file mode 100644 index 4d96c12e66..0000000000 --- a/querydsl-libraries/querydsl-hibernate-search/src/test/resources/derby.properties +++ /dev/null @@ -1,15 +0,0 @@ -## Derby -hibernate.dialect=org.hibernate.dialect.DerbyDialect -hibernate.connection.driver_class=org.apache.derby.jdbc.EmbeddedDriver -hibernate.connection.url=jdbc:derby:target/derbydb;create=true -hibernate.connection.pool_size=0 - -## Common properties -hibernate.show_sql=false -hibernate.flushMode=FLUSH_AUTO -hibernate.hbm2ddl.auto=update - -hibernate.search.default.directory_provider=org.hibernate.search.store.impl.FSDirectoryProvider -hibernate.search.default.indexBase=target/lucene/indexes -hibernate.search.default.batch.merge_factor=10 -hibernate.search.default.batch.max_buffered_docs=10 diff --git a/querydsl-libraries/querydsl-lucene3/README.md b/querydsl-libraries/querydsl-lucene3/README.md deleted file mode 100644 index 898825b003..0000000000 --- a/querydsl-libraries/querydsl-lucene3/README.md +++ /dev/null @@ -1,59 +0,0 @@ -## Querydsl Lucene 3 - -The Lucene module provides integration with the Lucene 3 indexing library. - -**Maven integration** - - Add the following dependencies to your Maven project : - -```XML - - io.github.openfeign.querydsl - querydsl-lucene3 - ${querydsl.version} - -``` - -**Creating the query types** - -With fields year and title a manually created query type could look something like this: - -```JAVA -public class QDocument extends EntityPathBase{ - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final StringPath year = createString("year"); - - public final StringPath title = createString("title"); -} -``` - -QDocument represents a Lucene document with the fields year and title. - -Code generation is not available for Lucene, since no schema data is available. - -**Querying** - -Querying with Querydsl Lucene is as simple as this: - -```JAVA -QDocument doc = new QDocument("doc"); - -IndexSearcher searcher = new IndexSearcher(index); -LuceneQuery query = new LuceneQuery(true, searcher); -List documents = query - .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle")) - .fetch(); - ``` - -which is transformed into the following Lucene query : - -``` -+year:[1800 TO 2000] +title:huckle* -``` - -For more information on the Querydsl Lucene module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s05.html diff --git a/querydsl-libraries/querydsl-lucene3/pom.xml b/querydsl-libraries/querydsl-lucene3/pom.xml deleted file mode 100644 index 54437d3498..0000000000 --- a/querydsl-libraries/querydsl-lucene3/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - 4.0.0 - - - io.github.openfeign.querydsl - querydsl-libraries - 6.0-SNAPSHOT - - - querydsl-lucene3 - Querydsl - Lucene 3 support - Lucene support for Querydsl - - - 3.6.2 - org.apache.lucene.*;version="[3.6,4)", - ${osgi.import.package.root} - - - - - org.jetbrains - annotations - provided - - - org.apache.lucene - lucene-core - ${lucene.version} - provided - - - org.apache.lucene - lucene-queries - ${lucene.version} - provided - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - - - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - test-jar - test - - - - io.github.openfeign.querydsl - querydsl-apt - ${project.version} - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - com.querydsl.lucene3 - - - - - - - org.apache.felix - maven-bundle-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - - com.querydsl.apt.QuerydslAnnotationProcessor - - - - - - diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/AbstractLuceneQuery.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/AbstractLuceneQuery.java deleted file mode 100644 index ed518222fd..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/AbstractLuceneQuery.java +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.EmptyCloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.Fetchable; -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.SimpleQuery; -import com.querydsl.core.support.QueryMixin; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.ParamExpression; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.Predicate; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.FieldSelector; -import org.apache.lucene.document.MapFieldSelector; -import org.apache.lucene.search.ChainedFilter; -import org.apache.lucene.search.DuplicateFilter; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TotalHitCountCollector; -import org.jetbrains.annotations.Nullable; - -/** - * AbstractLuceneQuery is an abstract super class for Lucene query implementations - * - * @author tiwe - * @param projection type - * @param concrete subtype of query - */ -public abstract class AbstractLuceneQuery> - implements SimpleQuery, Fetchable { - - private static final String JAVA_ISO_CONTROL = "[\\p{Cntrl}&&[^\r\n\t]]"; - - private final QueryMixin queryMixin; - - private final IndexSearcher searcher; - - private final LuceneSerializer serializer; - - private final Function transformer; - - @Nullable private FieldSelector fieldSelector; - - private List filters = Collections.emptyList(); - - @Nullable private Filter filter; - - @Nullable private Sort querySort; - - @SuppressWarnings("unchecked") - public AbstractLuceneQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - queryMixin = new QueryMixin((Q) this, new DefaultQueryMetadata()); - this.serializer = serializer; - this.searcher = searcher; - this.transformer = transformer; - } - - public AbstractLuceneQuery(IndexSearcher searcher, Function transformer) { - this(LuceneSerializer.DEFAULT, searcher, transformer); - } - - private long innerCount() { - try { - final int maxDoc = searcher.maxDoc(); - if (maxDoc == 0) { - return 0; - } - TotalHitCountCollector collector = new TotalHitCountCollector(); - searcher.search(createQuery(), getFilter(), collector); - return collector.getTotalHits(); - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public long fetchCount() { - return innerCount(); - } - - protected Query createQuery() { - if (queryMixin.getMetadata().getWhere() == null) { - return new MatchAllDocsQuery(); - } - return serializer.toQuery(queryMixin.getMetadata().getWhere(), queryMixin.getMetadata()); - } - - /** - * Create a filter for constraints defined in this query - * - * @return filter - */ - public Filter asFilter() { - return new QueryWrapperFilter(createQuery()); - } - - @Override - public Q distinct() { - throw new UnsupportedOperationException("use distinct(path) instead"); - } - - /** - * Add a DuplicateFilter for the field of the given property path - * - * @param property distinct property - * @return the current object - */ - public Q distinct(Path property) { - return filter(new DuplicateFilter(serializer.toField(property))); - } - - /** - * Apply the given Lucene filter to the search results - * - * @param filter filter - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q filter(Filter filter) { - if (filters.isEmpty()) { - this.filter = filter; - filters = Collections.singletonList(filter); - } else { - this.filter = null; - if (filters.size() == 1) { - filters = new ArrayList(); - } - filters.add(filter); - } - return (Q) this; - } - - private Filter getFilter() { - if (filter == null && !filters.isEmpty()) { - filter = new ChainedFilter(filters.toArray(new Filter[0])); - } - return filter; - } - - @Override - public Q limit(long limit) { - return queryMixin.limit(limit); - } - - @Override - public CloseableIterator iterate() { - final QueryMetadata metadata = queryMixin.getMetadata(); - final List> orderBys = metadata.getOrderBy(); - final Integer queryLimit = metadata.getModifiers().getLimitAsInteger(); - final Integer queryOffset = metadata.getModifiers().getOffsetAsInteger(); - Sort sort = querySort; - int limit; - final int offset = queryOffset != null ? queryOffset : 0; - try { - limit = maxDoc(); - if (limit == 0) { - return new EmptyCloseableIterator(); - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - if (queryLimit != null && queryLimit < limit) { - limit = queryLimit; - } - if (sort == null && !orderBys.isEmpty()) { - sort = serializer.toSort(orderBys); - } - - try { - ScoreDoc[] scoreDocs; - int sumOfLimitAndOffset = limit + offset; - if (sumOfLimitAndOffset < 1) { - throw new QueryException( - "The given limit (" - + limit - + ") and offset (" - + offset - + ") cause an integer overflow."); - } - if (sort != null) { - scoreDocs = - searcher.search(createQuery(), getFilter(), sumOfLimitAndOffset, sort).scoreDocs; - } else { - scoreDocs = searcher.search(createQuery(), getFilter(), sumOfLimitAndOffset).scoreDocs; - } - if (offset < scoreDocs.length) { - return new ResultIterator(scoreDocs, offset, searcher, fieldSelector, transformer); - } - return new EmptyCloseableIterator(); - } catch (final IOException e) { - throw new QueryException(e); - } - } - - private List innerList() { - return new IteratorAdapter(iterate()).asList(); - } - - @Override - public List fetch() { - return innerList(); - } - - /** - * Set the given FieldSelector to the query - * - * @param fieldSelector field selector - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(FieldSelector fieldSelector) { - this.fieldSelector = fieldSelector; - return (Q) this; - } - - /** - * Load only the fields of the given paths - * - * @param paths fields to load - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(Path... paths) { - List fields = new ArrayList(paths.length); - for (Path path : paths) { - fields.add(serializer.toField(path)); - } - this.fieldSelector = new MapFieldSelector(fields); - return (Q) this; - } - - @Override - public QueryResults fetchResults() { - List documents = innerList(); - /* - * TODO Get rid of fetchCount(). It could be implemented by iterating the - * fetch results in fetch* from n to m. - */ - return new QueryResults(documents, queryMixin.getMetadata().getModifiers(), innerCount()); - } - - @Override - public Q offset(long offset) { - return queryMixin.offset(offset); - } - - public Q orderBy(OrderSpecifier o) { - return queryMixin.orderBy(o); - } - - @Override - public Q orderBy(OrderSpecifier... o) { - return queryMixin.orderBy(o); - } - - @Override - public Q restrict(QueryModifiers modifiers) { - return queryMixin.restrict(modifiers); - } - - @Override - public

Q set(ParamExpression

param, P value) { - return queryMixin.set(param, value); - } - - @SuppressWarnings("unchecked") - public Q sort(Sort sort) { - this.querySort = sort; - return (Q) this; - } - - @Nullable - private T oneResult(boolean unique) { - try { - int maxDoc = maxDoc(); - if (maxDoc == 0) { - return null; - } - final ScoreDoc[] scoreDocs = searcher.search(createQuery(), getFilter(), maxDoc).scoreDocs; - int index = 0; - QueryModifiers modifiers = queryMixin.getMetadata().getModifiers(); - Long offset = modifiers.getOffset(); - if (offset != null) { - index = offset.intValue(); - } - Long limit = modifiers.getLimit(); - if (unique - && (limit == null ? scoreDocs.length - index > 1 : limit > 1 && scoreDocs.length > 1)) { - throw new NonUniqueResultException( - "Unique result requested, but " + scoreDocs.length + " found."); - } else if (scoreDocs.length > index) { - Document document; - if (fieldSelector != null) { - document = searcher.doc(scoreDocs[index].doc, fieldSelector); - } else { - document = searcher.doc(scoreDocs[index].doc); - } - return transformer.apply(document); - } else { - return null; - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public T fetchFirst() { - return oneResult(false); - } - - @Override - public T fetchOne() throws NonUniqueResultException { - return oneResult(true); - } - - public Q where(Predicate e) { - return queryMixin.where(e); - } - - @Override - public Q where(Predicate... e) { - return queryMixin.where(e); - } - - @Override - public String toString() { - return createQuery().toString().replaceAll(JAVA_ISO_CONTROL, "_"); - } - - private int maxDoc() throws IOException { - return searcher.maxDoc(); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/IgnoreCaseUnsupportedException.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/IgnoreCaseUnsupportedException.java deleted file mode 100644 index 79bbabed31..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/IgnoreCaseUnsupportedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -/** - * Thrown for case ignore usage - * - * @author tiwe - */ -public class IgnoreCaseUnsupportedException extends UnsupportedOperationException { - - private static final long serialVersionUID = 412913389929530788L; - - public IgnoreCaseUnsupportedException() { - super("Ignore case queries are not supported with Lucene"); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneExpressions.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneExpressions.java deleted file mode 100644 index 5539335652..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneExpressions.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.BooleanExpression; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.FuzzyQuery; - -/** - * Utility methods to create filter expressions for Lucene queries that are not covered by the - * Querydsl standard expression model - * - * @author tiwe - */ -public final class LuceneExpressions { - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @return condition - */ - public static BooleanExpression fuzzyLike(Path path, String value) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param minimumSimilarity a value between 0 and 1 to set the required similarity - * @return condition - */ - public static BooleanExpression fuzzyLike( - Path path, String value, float minimumSimilarity) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, minimumSimilarity)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param minimumSimilarity a value between 0 and 1 to set the required similarity - * @param prefixLength length of common (non-fuzzy) prefix - * @return condition - */ - public static BooleanExpression fuzzyLike( - Path path, String value, float minimumSimilarity, int prefixLength) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, minimumSimilarity, prefixLength)); - } - - private LuceneExpressions() {} -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneOps.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneOps.java deleted file mode 100644 index cc598e440b..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneOps.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.Operator; - -/** - * Lucene specific operators - * - * @author tiwe - */ -public enum LuceneOps implements Operator { - LUCENE_QUERY(Object.class), - PHRASE(String.class), - TERM(String.class); - - private final Class type; - - LuceneOps(Class type) { - this.type = type; - } - - @Override - public Class getType() { - return type; - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneQuery.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneQuery.java deleted file mode 100644 index ead825a659..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneQuery.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code LuceneQuery} is a Querydsl query implementation for Lucene queries. - * - *

Example: - * - *

{@code
- * QDocument doc = new QDocument("doc");
- *
- * IndexSearcher searcher = new IndexSearcher(index);
- * LuceneQuery query = new LuceneQuery(true, searcher);
- * List documents = query
- *     .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- *     .fetch();
- * }
- * - * @author vema - */ -public class LuceneQuery extends AbstractLuceneQuery { - - private static final Function TRANSFORMER = - new Function() { - @Override - public Document apply(Document input) { - return input; - } - }; - - public LuceneQuery(IndexSearcher searcher) { - super(searcher, TRANSFORMER); - } - - public LuceneQuery(LuceneSerializer luceneSerializer, IndexSearcher searcher) { - super(luceneSerializer, searcher, TRANSFORMER); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneSerializer.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneSerializer.java deleted file mode 100644 index 1fac8516ba..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/LuceneSerializer.java +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.*; -import org.apache.lucene.index.Term; -import org.apache.lucene.queryParser.QueryParser; -import org.apache.lucene.search.*; -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.util.NumericUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Serializes Querydsl queries to Lucene queries. - * - * @author vema - */ -public class LuceneSerializer { - private static final Map, Integer> sortFields = new HashMap, Integer>(); - - static { - sortFields.put(Integer.class, SortField.INT); - sortFields.put(Float.class, SortField.FLOAT); - sortFields.put(Long.class, SortField.LONG); - sortFields.put(Double.class, SortField.DOUBLE); - sortFields.put(Short.class, SortField.SHORT); - sortFields.put(Byte.class, SortField.BYTE); - sortFields.put(BigDecimal.class, SortField.DOUBLE); - sortFields.put(BigInteger.class, SortField.LONG); - } - - public static final LuceneSerializer DEFAULT = new LuceneSerializer(false, true); - - private final boolean lowerCase; - - private final boolean splitTerms; - - private final Locale sortLocale; - - public LuceneSerializer(boolean lowerCase, boolean splitTerms) { - this(lowerCase, splitTerms, Locale.getDefault()); - } - - public LuceneSerializer(boolean lowerCase, boolean splitTerms, Locale sortLocale) { - this.lowerCase = lowerCase; - this.splitTerms = splitTerms; - this.sortLocale = sortLocale; - } - - private Query toQuery(Operation operation, QueryMetadata metadata) { - Operator op = operation.getOperator(); - if (op == Ops.OR) { - return toTwoHandSidedQuery(operation, Occur.SHOULD, metadata); - } else if (op == Ops.AND) { - return toTwoHandSidedQuery(operation, Occur.MUST, metadata); - } else if (op == Ops.NOT) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(toQuery(operation.getArg(0), metadata), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } else if (op == Ops.LIKE) { - return like(operation, metadata); - } else if (op == Ops.LIKE_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.EQ) { - return eq(operation, metadata, false); - } else if (op == Ops.EQ_IGNORE_CASE) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.NE) { - return ne(operation, metadata, false); - } else if (op == Ops.STARTS_WITH) { - return startsWith(metadata, operation, false); - } else if (op == Ops.STARTS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.ENDS_WITH) { - return endsWith(operation, metadata, false); - } else if (op == Ops.ENDS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.STRING_CONTAINS) { - return stringContains(operation, metadata, false); - } else if (op == Ops.STRING_CONTAINS_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.BETWEEN) { - return between(operation, metadata); - } else if (op == Ops.IN) { - return in(operation, metadata, false); - } else if (op == Ops.NOT_IN) { - return notIn(operation, metadata, false); - } else if (op == Ops.LT) { - return lt(operation, metadata); - } else if (op == Ops.GT) { - return gt(operation, metadata); - } else if (op == Ops.LOE) { - return le(operation, metadata); - } else if (op == Ops.GOE) { - return ge(operation, metadata); - } else if (op == LuceneOps.LUCENE_QUERY) { - @SuppressWarnings("unchecked") // This is the expected type - Query rv = ((Constant) operation.getArg(0)).getConstant(); - return rv; - } - throw new UnsupportedOperationException("Illegal operation " + operation); - } - - private Query toTwoHandSidedQuery(Operation operation, Occur occur, QueryMetadata metadata) { - Query lhs = toQuery(operation.getArg(0), metadata); - Query rhs = toQuery(operation.getArg(1), metadata); - BooleanQuery bq = new BooleanQuery(); - bq.add(createBooleanClause(lhs, occur)); - bq.add(createBooleanClause(rhs, occur)); - return bq; - } - - /** - * If the query is a BooleanQuery and it contains a single Occur.MUST_NOT clause it will be - * returned as is. Otherwise it will be wrapped in a BooleanClause with the given Occur. - */ - private BooleanClause createBooleanClause(Query query, Occur occur) { - if (query instanceof BooleanQuery) { - BooleanClause[] clauses = ((BooleanQuery) query).getClauses(); - if (clauses.length == 1 && clauses[0].getOccur().equals(Occur.MUST_NOT)) { - return clauses[0]; - } - } - return new BooleanClause(query, occur); - } - - protected Query like(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convert(path, operation.getArg(1)); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, terms[0])); - } - - protected Query eq(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - - if (Number.class.isAssignableFrom(operation.getArg(1).getType())) { - @SuppressWarnings("unchecked") // guarded by previous check - Constant rightArg = (Constant) operation.getArg(1); - return new TermQuery(new Term(field, convertNumber(rightArg.getConstant()))); - } - - return eq(field, convert(path, operation.getArg(1), metadata), ignoreCase); - } - - private String convertNumber(Number number) { - if (Integer.class.isInstance(number)) { - return NumericUtils.intToPrefixCoded(number.intValue()); - } else if (Double.class.isInstance(number)) { - return NumericUtils.doubleToPrefixCoded(number.doubleValue()); - } else if (Long.class.isInstance(number)) { - return NumericUtils.longToPrefixCoded(number.longValue()); - } else if (Float.class.isInstance(number)) { - return NumericUtils.floatToPrefixCoded(number.floatValue()); - } else if (Byte.class.isInstance(number)) { - return NumericUtils.intToPrefixCoded(number.intValue()); - } else if (Short.class.isInstance(number)) { - return NumericUtils.intToPrefixCoded(number.intValue()); - } else if (BigDecimal.class.isInstance(number)) { - return NumericUtils.doubleToPrefixCoded(number.doubleValue()); - } else if (BigInteger.class.isInstance(number)) { - return NumericUtils.longToPrefixCoded(number.longValue()); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + number.getClass().getName()); - } - } - - protected Query eq(String field, String[] terms, boolean ignoreCase) { - if (terms.length > 1) { - PhraseQuery pq = new PhraseQuery(); - for (String s : terms) { - pq.add(new Term(field, s)); - } - return pq; - } - return new TermQuery(new Term(field, terms[0])); - } - - protected Query in(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - Path path = getPath(operation.getArg(0)); - String field = toField(path); - @SuppressWarnings("unchecked") // This is the second argument type - Constant> collConstant = (Constant>) operation.getArg(1); - Collection values = collConstant.getConstant(); - BooleanQuery bq = new BooleanQuery(); - if (Number.class.isAssignableFrom(path.getType())) { - for (Object value : values) { - TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value))); - bq.add(eq, Occur.SHOULD); - } - } else { - for (Object value : values) { - String[] str = convert(path, value); - bq.add(eq(field, str, ignoreCase), Occur.SHOULD); - } - } - return bq; - } - - protected Query notIn(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(in(operation, metadata, false), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query ne(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(eq(operation, metadata, ignoreCase), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query startsWith(QueryMetadata metadata, Operation operation, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == 0 ? terms[i] + "*" : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new PrefixQuery(new Term(field, terms[0])); - } - - protected Query stringContains( - Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0] + "*")); - } - - protected Query endsWith(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == terms.length - 1 ? "*" + terms[i] : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0])); - } - - protected Query between(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - // TODO Phrase not properly supported - return range( - path, toField(path), operation.getArg(1), operation.getArg(2), true, true, metadata); - } - - protected Query lt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), false, false, metadata); - } - - protected Query gt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, false, false, metadata); - } - - protected Query le(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), true, true, metadata); - } - - protected Query ge(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, true, true, metadata); - } - - protected Query range( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - if (min != null && Number.class.isAssignableFrom(min.getType()) - || max != null && Number.class.isAssignableFrom(max.getType())) { - @SuppressWarnings("unchecked") // guarded by previous check - Constant minConstant = (Constant) min; - @SuppressWarnings("unchecked") // guarded by previous check - Constant maxConstant = (Constant) max; - - Class numType = - minConstant != null ? minConstant.getType() : maxConstant.getType(); - // this is not necessarily safe, but compile time checking - // on the user side mandates these types to be interchangeable - @SuppressWarnings("unchecked") - Class unboundedNumType = (Class) numType; - return numericRange( - unboundedNumType, - field, - minConstant == null ? null : minConstant.getConstant(), - maxConstant == null ? null : maxConstant.getConstant(), - minInc, - maxInc); - } - return stringRange(leftHandSide, field, min, max, minInc, maxInc, metadata); - } - - protected NumericRangeQuery numericRange( - Class clazz, - String field, - @Nullable N min, - @Nullable N max, - boolean minInc, - boolean maxInc) { - if (clazz.equals(Integer.class)) { - return NumericRangeQuery.newIntRange(field, (Integer) min, (Integer) max, minInc, maxInc); - } else if (clazz.equals(Double.class)) { - return NumericRangeQuery.newDoubleRange(field, (Double) min, (Double) max, minInc, minInc); - } else if (clazz.equals(Float.class)) { - return NumericRangeQuery.newFloatRange(field, (Float) min, (Float) max, minInc, minInc); - } else if (clazz.equals(Long.class)) { - return NumericRangeQuery.newLongRange(field, (Long) min, (Long) max, minInc, minInc); - } else if (clazz.equals(Byte.class) || clazz.equals(Short.class)) { - return NumericRangeQuery.newIntRange( - field, - min != null ? min.intValue() : null, - max != null ? max.intValue() : null, - minInc, - maxInc); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + clazz.getName()); - } - } - - protected Query stringRange( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - - if (min == null) { - return new TermRangeQuery( - field, null, convert(leftHandSide, max, metadata)[0], minInc, maxInc); - } else if (max == null) { - return new TermRangeQuery( - field, convert(leftHandSide, min, metadata)[0], null, minInc, maxInc); - } else { - return new TermRangeQuery( - field, - convert(leftHandSide, min, metadata)[0], - convert(leftHandSide, max, metadata)[0], - minInc, - maxInc); - } - } - - private Path getPath(Expression leftHandSide) { - if (leftHandSide instanceof Path) { - return (Path) leftHandSide; - } else if (leftHandSide instanceof Operation) { - Operation operation = (Operation) leftHandSide; - if (operation.getOperator() == Ops.LOWER || operation.getOperator() == Ops.UPPER) { - return (Path) operation.getArg(0); - } - } - throw new IllegalArgumentException("Unable to transform " + leftHandSide + " to path"); - } - - /** - * template method, override to customize - * - * @param path path - * @return field name - */ - protected String toField(Path path) { - PathMetadata md = path.getMetadata(); - if (md.getPathType() == PathType.COLLECTION_ANY) { - return toField(md.getParent()); - } else { - String rv = md.getName(); - if (md.getParent() != null) { - Path parent = md.getParent(); - if (parent.getMetadata().getPathType() != PathType.VARIABLE) { - rv = toField(parent) + "." + rv; - } - } - return rv; - } - } - - private void verifyArguments(Operation operation) { - List> arguments = operation.getArgs(); - for (int i = 1; i < arguments.size(); ++i) { - if (!(arguments.get(i) instanceof Constant) - && !(arguments.get(i) instanceof ParamExpression) - && !(arguments.get(i) instanceof PhraseElement) - && !(arguments.get(i) instanceof TermElement)) { - throw new IllegalArgumentException( - "operand was of unsupported type " + arguments.get(i).getClass().getName()); - } - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - if (rightHandSide instanceof Operation) { - Operation operation = (Operation) rightHandSide; - if (operation.getOperator() == LuceneOps.PHRASE) { - return operation.getArg(0).toString().split("\\s+"); - } else if (operation.getOperator() == LuceneOps.TERM) { - return new String[] {operation.getArg(0).toString()}; - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } else if (rightHandSide instanceof ParamExpression) { - Object value = metadata.getParams().get(rightHandSide); - if (value == null) { - throw new ParamNotSetException((ParamExpression) rightHandSide); - } - return convert(leftHandSide, value); - - } else if (rightHandSide instanceof Constant) { - return convert(leftHandSide, ((Constant) rightHandSide).getConstant()); - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert(Path leftHandSide, Object rightHandSide) { - String str = rightHandSide.toString(); - if (lowerCase) { - str = str.toLowerCase(); - } - if (splitTerms) { - if (str.equals("")) { - return new String[] {str}; - } else { - return str.split("\\s+"); - } - } else { - return new String[] {str}; - } - } - - private String[] convertEscaped( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - String[] str = convert(leftHandSide, rightHandSide, metadata); - for (int i = 0; i < str.length; i++) { - str[i] = QueryParser.escape(str[i]); - } - return str; - } - - public Query toQuery(Expression expr, QueryMetadata metadata) { - if (expr instanceof Operation) { - return toQuery((Operation) expr, metadata); - } else { - return toQuery(ExpressionUtils.extract(expr), metadata); - } - } - - public Sort toSort(List> orderBys) { - List sorts = new ArrayList(orderBys.size()); - for (OrderSpecifier order : orderBys) { - if (!(order.getTarget() instanceof Path)) { - throw new IllegalArgumentException("argument was not of type Path."); - } - Class type = order.getTarget().getType(); - boolean reverse = !order.isAscending(); - Path path = getPath(order.getTarget()); - if (Number.class.isAssignableFrom(type)) { - sorts.add(new SortField(toField(path), sortFields.get(type), reverse)); - } else { - sorts.add(new SortField(toField(path), sortLocale, reverse)); - } - } - Sort sort = new Sort(); - sort.setSort(sorts.toArray(new SortField[0])); - return sort; - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/PhraseElement.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/PhraseElement.java deleted file mode 100644 index f0e855cbc0..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/PhraseElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code PhraseElement} represents the embedded String as a phrase - * - * @author tiwe - */ -public class PhraseElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public PhraseElement(String str) { - super(LuceneOps.PHRASE, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/QueryElement.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/QueryElement.java deleted file mode 100644 index 340312ec27..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/QueryElement.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.BooleanOperation; -import org.apache.lucene.search.Query; - -/** - * {@code QueryElement} wraps a Lucene Query - * - * @author tiwe - */ -public class QueryElement extends BooleanOperation { - - private static final long serialVersionUID = 470868107363840155L; - - public QueryElement(Query query) { - super(LuceneOps.LUCENE_QUERY, ConstantImpl.create(query)); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/ResultIterator.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/ResultIterator.java deleted file mode 100644 index 30ed43dd7e..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/ResultIterator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.mysema.commons.lang.CloseableIterator; -import com.querydsl.core.QueryException; -import java.io.IOException; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.FieldSelector; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.ScoreDoc; -import org.jetbrains.annotations.Nullable; - -/** - * {@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results - * - * @author tiwe - * @param - */ -public final class ResultIterator implements CloseableIterator { - - private final ScoreDoc[] scoreDocs; - - private int cursor; - - private final IndexSearcher searcher; - - @Nullable private final FieldSelector fieldSelector; - - private final Function transformer; - - public ResultIterator( - ScoreDoc[] scoreDocs, - int offset, - IndexSearcher searcher, - @Nullable FieldSelector fieldSelector, - Function transformer) { - this.scoreDocs = scoreDocs.clone(); - this.cursor = offset; - this.searcher = searcher; - this.fieldSelector = fieldSelector; - this.transformer = transformer; - } - - @Override - public boolean hasNext() { - return cursor != scoreDocs.length; - } - - @Override - public T next() { - try { - Document document; - if (fieldSelector != null) { - document = searcher.doc(scoreDocs[cursor++].doc, fieldSelector); - } else { - document = searcher.doc(scoreDocs[cursor++].doc); - } - return transformer.apply(document); - } catch (IOException e) { - throw new QueryException(e); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public void close() {} -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TermElement.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TermElement.java deleted file mode 100644 index e4b6b13adc..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TermElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code TermElement} represents the embedded String as a term - * - * @author tiwe - */ -public class TermElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public TermElement(String str) { - super(LuceneOps.TERM, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TypedQuery.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TypedQuery.java deleted file mode 100644 index 76baca5cc7..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/TypedQuery.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code TypedQuery} is a typed query implementation for Lucene queries. - * - *

Converts Lucene documents to typed results via a constructor supplied transformer - * - * @param result type - * @author laim - * @author tiwe - */ -public class TypedQuery extends AbstractLuceneQuery> { - - /** - * Create a new TypedQuery instance - * - * @param searcher index searcher - * @param transformer transformer to transform Lucene documents to result objects - */ - public TypedQuery(IndexSearcher searcher, Function transformer) { - super(searcher, transformer); - } - - /** - * Create a new TypedQuery instance - * - * @param serializer serializer - * @param searcher index search - * @param transformer transformer to transform documents to result objects - */ - public TypedQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - super(serializer, searcher, transformer); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/package-info.java b/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/package-info.java deleted file mode 100644 index 777d96cb34..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/main/java/com/querydsl/lucene3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Lucene 3 support */ -package com.querydsl.lucene3; diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneQueryTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneQueryTest.java deleted file mode 100644 index 53d01d745f..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneQueryTest.java +++ /dev/null @@ -1,745 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.easymock.EasyMock.*; - -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.types.ParamNotSetException; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.Param; -import com.querydsl.core.types.dsl.StringPath; -import java.io.IOException; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.MapFieldSelector; -import org.apache.lucene.document.NumericField; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.DuplicateFilter; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Sort; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneQuery - * - * @author vema - */ -public class LuceneQueryTest { - - private LuceneQuery query; - private StringPath title; - private NumberPath year; - private NumberPath gross; - - private final StringPath sort = Expressions.stringPath("sort"); - - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - - private Document createDocument( - final String docTitle, - final String docAuthor, - final String docText, - final int docYear, - final double docGross) { - final Document doc = new Document(); - - doc.add(new Field("title", docTitle, Store.YES, Index.ANALYZED)); - doc.add(new Field("author", docAuthor, Store.YES, Index.ANALYZED)); - doc.add(new Field("text", docText, Store.YES, Index.ANALYZED)); - doc.add(new NumericField("year", Store.YES, true).setIntValue(docYear)); - doc.add(new NumericField("gross", Store.YES, true).setDoubleValue(docGross)); - - return doc; - } - - @Before - public void setUp() throws Exception { - final QDocument entityPath = new QDocument("doc"); - title = entityPath.title; - year = entityPath.year; - gross = entityPath.gross; - - idx = new RAMDirectory(); - writer = createWriter(idx); - - writer.addDocument( - createDocument( - "Jurassic Park", "Michael Crichton", "It's a UNIX system! I know this!", 1990, 90.00)); - writer.addDocument( - createDocument( - "Nummisuutarit", "Aleksis Kivi", "ESKO. Ja iloitset ja riemuitset?", 1864, 10.00)); - writer.addDocument( - createDocument( - "The Lord of the Rings", - "John R. R. Tolkien", - "One Ring to rule them all, One Ring to find them, One Ring to bring them all and in" - + " the darkness bind them", - 1954, - 89.00)); - writer.addDocument( - createDocument( - "Introduction to Algorithms", - "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein", - "Bubble sort", - 1990, - 30.50)); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - } - - private IndexWriter createWriter(RAMDirectory idx) throws Exception { - IndexWriterConfig config = - new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_30)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - return new IndexWriter(idx, config); - } - - @After - public void tearDown() throws Exception { - searcher.close(); - } - - @Test - public void between() { - assertThat(query.where(year.between(1950, 1990)).fetchCount()).isEqualTo(3); - } - - @Test - public void count_empty_where_clause() { - assertThat(query.fetchCount()).isEqualTo(4); - } - - @Test - public void exists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() > 0).isTrue(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() > 0).isFalse(); - } - - @Test - public void notExists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() == 0).isFalse(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() == 0).isTrue(); - } - - @Test - public void count() { - query.where(title.eq("Jurassic Park")); - assertThat(query.fetchCount()).isEqualTo(1); - } - - @Test(expected = QueryException.class) - public void count_index_problem() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchCount(); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void countDistinct() { - query.where(year.between(1900, 3000)); - assertThat(query.distinct().fetchCount()).isEqualTo(3); - } - - @Test - public void in() { - assertThat(query.where(title.in("Jurassic Park", "Nummisuutarit")).fetchCount()).isEqualTo(2); - } - - @Test - public void in2() { - assertThat(query.where(year.in(1990, 1864)).fetchCount()).isEqualTo(3); - } - - @Test - public void in_toString() { - assertThat(query.where(year.in(1990, 1864)).toString()).isEqualTo("year:`____F year:`____H"); - } - - @Test - public void list_sorted_by_year_ascending() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted() { - query.where(year.between(1800, 2000)); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void sorted_by_different_locales() throws Exception { - Document d1 = new Document(); - Document d2 = new Document(); - Document d3 = new Document(); - d1.add(new Field("sort", "a\u00c4", Store.YES, Index.NOT_ANALYZED)); - d2.add(new Field("sort", "ab", Store.YES, Index.NOT_ANALYZED)); - d3.add(new Field("sort", "aa", Store.YES, Index.NOT_ANALYZED)); - writer = createWriter(idx); - writer.addDocument(d1); - writer.addDocument(d2); - writer.addDocument(d3); - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.ENGLISH), searcher); - assertThat(query.fetch()).hasSize(3); - List results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results).hasSize(3); - assertThat(results.getFirst().getFieldable("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getFieldable("sort").stringValue()).isEqualTo("a\u00c4"); - assertThat(results.get(2).getFieldable("sort").stringValue()).isEqualTo("ab"); - - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.of("fi", "FI")), searcher); - results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results.getFirst().getFieldable("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getFieldable("sort").stringValue()).isEqualTo("ab"); - assertThat(results.get(2).getFieldable("sort").stringValue()).isEqualTo("a\u00c4"); - } - - @Test - public void list_not_sorted_limit_2() { - query.where(year.between(1800, 2000)); - query.limit(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_by_year_limit_1() { - query.where(year.between(1800, 2000)); - query.limit(1); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(1); - } - - @Test - public void list_not_sorted_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_ascending_by_year_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year_restrict_limit_2_offset_1() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1954"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sort() { - Sort sort = LuceneSerializer.DEFAULT.toSort(Collections.singletonList(year.asc())); - - query.where(year.between(1800, 2000)); - // query.orderBy(year.asc()); - query.sort(sort); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_distinct_property() { - assertThat(query.fetch()).hasSize(4); - assertThat(query.distinct(year).fetch()).hasSize(3); - } - - @Test - public void list_with_filter() { - Filter filter = new DuplicateFilter("year"); - assertThat(query.fetch()).hasSize(4); - assertThat(query.filter(filter).fetch()).hasSize(3); - } - - @Test - public void count_distinct_property() { - assertThat(query.fetchCount()).isEqualTo(4L); - assertThat(query.distinct(year).fetchCount()).isEqualTo(3L); - } - - @Test - public void list_sorted_descending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.get(2).get("year")).isEqualTo("1954"); - assertThat(documents.get(3).get("year")).isEqualTo("1864"); - } - - @Test - public void list_sorted_descending_by_gross() { - query.where(gross.between(0.0, 1000.00)); - query.orderBy(gross.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("gross")).isEqualTo("90.0"); - assertThat(documents.get(1).get("gross")).isEqualTo("89.0"); - assertThat(documents.get(2).get("gross")).isEqualTo("30.5"); - assertThat(documents.get(3).get("gross")).isEqualTo("10.0"); - } - - @Test - public void list_sorted_descending_by_year_and_ascending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Introduction to Algorithms"); - assertThat(documents.get(1).get("title")).isEqualTo("Jurassic Park"); - } - - @Test - public void list_sorted_descending_by_year_and_descending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Jurassic Park"); - assertThat(documents.get(1).get("title")).isEqualTo("Introduction to Algorithms"); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetch(); - verify(searcher); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.orderBy(title.asc()); - query.fetch(); - verify(searcher); - } - - @Test - public void offset() { - assertThat(query.where(title.eq("Jurassic Park")).offset(30).fetch()).isEmpty(); - } - - @Test - public void load_list() { - Document document = query.where(title.ne("")).load(title).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_list_fieldSelector() { - Document document = - query.where(title.ne("")).load(new MapFieldSelector("title")).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult() { - Document document = query.where(title.ne("")).load(title).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult_fieldSelector() { - Document document = query.where(title.ne("")).load(new MapFieldSelector("title")).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void singleResult() { - assertThat(query.where(title.ne("")).fetchFirst()).isNotNull(); - } - - @Test - public void single_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchFirst().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void single_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchFirst(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void single_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchFirst()).isNull(); - } - - @Test - public void single_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchFirst().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void single_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchFirst().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test(expected = NonUniqueResultException.class) - public void uniqueResult_contract() { - query.where(title.ne("")).fetchOne(); - } - - @Test - public void unique_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchOne().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void unique_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void unique_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchOne()).isNull(); - } - - @Test - public void unique_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchOne().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void unique_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchOne().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test - public void uniqueResult() { - query.where(title.startsWith("Nummi")); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void uniqueResult_with_param() { - final Param param = new Param(String.class, "title"); - query.set(param, "Nummi"); - query.where(title.startsWith(param)); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test(expected = ParamNotSetException.class) - public void uniqueResult_param_not_set() { - final Param param = new Param(String.class, "title"); - query.where(title.startsWith(param)); - query.fetchOne(); - } - - @Test(expected = QueryException.class) - public void uniqueResult_finds_more_than_one_result() { - query.where(year.eq(1990)); - query.fetchOne(); - } - - @Test - public void uniqueResult_finds_no_results() { - query.where(year.eq(2200)); - assertThat(query.fetchOne()).isNull(); - } - - @Test - public void uniqueResult_finds_no_results_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchOne()).isNull(); - verify(searcher); - } - - @Test(expected = QueryException.class) - public void uniqueResult_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchOne(); - verify(searcher); - } - - @Test - public void count_returns_0_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchCount()).isEqualTo(0); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinct() { - query.where(year.between(1900, 2000).or(title.startsWith("Jura"))); - query.orderBy(year.asc()); - final List documents = query.distinct().fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(3); - } - - @Test - public void listResults() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getResults().get(1).get("year")).isEqualTo("1990"); - assertThat(results.getLimit()).isEqualTo(2); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinctResults() { - query.where(year.between(1800, 2000).or(title.eq("The Lord of the Rings"))); - query.restrict(new QueryModifiers(1L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.distinct().fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getLimit()).isEqualTo(1); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test - public void list_all() { - final List results = - query.where(title.like("*")).orderBy(title.asc(), year.desc()).fetch(); - assertThat(results).hasSize(4); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.fetch(); - } - - @Test - public void list_sorted_ascending_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void iterate() { - query.where(year.between(1800, 2000)); - final Iterator iterator = query.iterate(); - int count = 0; - while (iterator.hasNext()) { - iterator.next(); - ++count; - } - assertThat(count).isEqualTo(4); - } - - @Test - public void all_by_excluding_where() { - assertThat(query.fetch()).hasSize(4); - } - - @Test - public void empty_index_should_return_empty_list() throws Exception { - idx = new RAMDirectory(); - - writer = createWriter(idx); - writer.close(); - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - assertThat(query.fetch()).isEmpty(); - } - - @Test(expected = QueryException.class) - public void - list_results_throws_an_illegal_argument_exception_when_sum_of_limit_and_offset_is_negative() { - query.limit(1).offset(Integer.MAX_VALUE).fetchResults(); - } - - @Test - public void limit_max_value() { - assertThat(query.limit(Long.MAX_VALUE).fetch()).hasSize(4); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerNotTokenizedTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerNotTokenizedTest.java deleted file mode 100644 index 718e2edf97..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerNotTokenizedTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static com.querydsl.lucene3.QPerson.person; -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import java.time.LocalDate; -import java.util.Arrays; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; -import org.junit.Before; -import org.junit.Test; - -public class LuceneSerializerNotTokenizedTest { - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - private LuceneSerializer serializer; - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private final Person clooney = new Person("actor_1", "George Clooney", LocalDate.of(1961, 4, 6)); - private final Person pitt = new Person("actor_2", "Brad Pitt", LocalDate.of(1963, 12, 18)); - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - private Document createDocument(Person person) { - Document doc = new Document(); - doc.add(new Field("id", person.getId(), Store.YES, Index.NOT_ANALYZED)); - doc.add(new Field("name", person.getName(), Store.YES, Index.NOT_ANALYZED)); - doc.add( - new Field("birthDate", person.getBirthDate().toString(), Store.YES, Index.NOT_ANALYZED)); - return doc; - } - - @Before - public void before() throws Exception { - serializer = new LuceneSerializer(false, false); - idx = new RAMDirectory(); - IndexWriterConfig config = - new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_30)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument(clooney)); - writer.addDocument(createDocument(pitt)); - - Document document = new Document(); - for (String movie : Arrays.asList("Interview with the Vampire", "Up in the Air")) { - document.add(new Field("movie", movie, Store.YES, Index.NOT_ANALYZED)); - } - writer.addDocument(document); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @Test - public void equals_by_id_matches() throws Exception { - testQuery(person.id.eq("actor_1"), "id:actor_1", 1); - } - - @Test - public void equals_by_id_does_not_match() throws Exception { - testQuery(person.id.eq("actor_8"), "id:actor_8", 0); - } - - @Test - public void equals_by_name_matches() throws Exception { - testQuery(person.name.eq("George Clooney"), "name:George Clooney", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_by_name_ignoring_case_does_not_match() throws Exception { - testQuery(person.name.equalsIgnoreCase("george clooney"), "name:george clooney", 0); - } - - @Test - public void equals_by_name_does_not_match() throws Exception { - testQuery(person.name.eq("George Looney"), "name:George Looney", 0); - } - - @Test - public void starts_with_name_should_match() throws Exception { - testQuery(person.name.startsWith("George C"), "name:George C*", 1); - } - - @Test - public void starts_with_name_should_not_match() throws Exception { - testQuery(person.name.startsWith("George L"), "name:George L*", 0); - } - - @Test - public void ends_with_name_should_match() throws Exception { - testQuery(person.name.endsWith("e Clooney"), "name:*e Clooney", 1); - } - - @Test - public void ends_with_name_should_not_match() throws Exception { - testQuery(person.name.endsWith("e Looney"), "name:*e Looney", 0); - } - - @Test - public void contains_name_should_match() throws Exception { - testQuery(person.name.contains("oney"), "name:*oney*", 1); - } - - @Test - public void contains_name_should_not_match() throws Exception { - testQuery(person.name.contains("bloney"), "name:*bloney*", 0); - } - - @Test - public void in_names_should_match_2() throws Exception { - testQuery( - person.name.in("Brad Pitt", "George Clooney"), "name:Brad Pitt name:George Clooney", 2); - } - - @Test - public void or_by_name_should_match_2() throws Exception { - testQuery( - person.name.eq("Brad Pitt").or(person.name.eq("George Clooney")), - "name:Brad Pitt name:George Clooney", - 2); - } - - @Test - public void equals_by_birth_date() throws Exception { - testQuery(person.birthDate.eq(clooney.getBirthDate()), "birthDate:1961-04-06", 1); - } - - @Test - public void between_phrase() throws Exception { - testQuery( - person.name.between("Brad Pitt", "George Clooney"), - "name:[Brad Pitt TO George Clooney]", - 2); - } - - @Test - public void not_equals_finds_the_actors_and_movies() throws Exception { - testQuery(person.name.ne("Michael Douglas"), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void not_equals_finds_only_clooney_and_movies() throws Exception { - testQuery(person.name.ne("Brad Pitt"), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void and_with_two_not_equals_doesnt_find_the_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").and(person.name.ne("George Clooney")), - "+(-name:Brad Pitt +*:*) +(-name:George Clooney +*:*)", - 1); - } - - @Test - public void or_with_two_not_equals_finds_movies_and_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").or(person.name.ne("George Clooney")), - "(-name:Brad Pitt +*:*) (-name:George Clooney +*:*)", - 3); - } - - @Test - public void negation_of_equals_finds_movies_and_actors() throws Exception { - testQuery(person.name.eq("Michael Douglas").not(), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void negation_of_equals_finds_pitt_and_movies() throws Exception { - testQuery(person.name.eq("Brad Pitt").not(), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void multiple_field_search_from_movies() throws Exception { - StringPath movie = Expressions.stringPath("movie"); - testQuery(movie.in("Interview with the Vampire"), "movie:Interview with the Vampire", 1); - testQuery(movie.eq("Up in the Air"), "movie:Up in the Air", 1); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerTest.java deleted file mode 100644 index b46810dda3..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/LuceneSerializerTest.java +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.junit.jupiter.api.Assertions.*; - -import com.querydsl.core.*; -import com.querydsl.core.types.*; -import com.querydsl.core.types.dsl.*; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Set; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.NumericField; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.NumericUtils; -import org.apache.lucene.util.Version; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneSerializer - * - * @author vema - */ -public class LuceneSerializerTest { - private LuceneSerializer serializer; - private PathBuilder entityPath; - private StringPath title; - private StringPath author; - private StringPath text; - private StringPath rating; - private StringPath publisher; - private NumberPath year; - private NumberPath gross; - private CollectionPath titles; - - private NumberPath longField; - private NumberPath shortField; - private NumberPath byteField; - private NumberPath floatField; - - private static final String YEAR_PREFIX_CODED = NumericUtils.intToPrefixCoded(1990); - private static final String GROSS_PREFIX_CODED = NumericUtils.doubleToPrefixCoded(900.00); - private static final String LONG_PREFIX_CODED = NumericUtils.longToPrefixCoded(1); - private static final String SHORT_PREFIX_CODED = NumericUtils.intToPrefixCoded(1); - private static final String BYTE_PREFIX_CODED = NumericUtils.intToPrefixCoded(1); - private static final String FLOAT_PREFIX_CODED = NumericUtils.floatToPrefixCoded((float) 1.0); - - private IndexWriterConfig config; - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - - private static final Set UNSUPPORTED_OPERATORS = - Collections.unmodifiableSet( - EnumSet.of( - Ops.STARTS_WITH_IC, Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC)); - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private Document createDocument() { - Document doc = new Document(); - - doc.add(new Field("title", new StringReader("Jurassic Park"))); - doc.add(new Field("author", new StringReader("Michael Crichton"))); - doc.add(new Field("text", new StringReader("It's a UNIX system! I know this!"))); - doc.add(new Field("rating", new StringReader("Good"))); - doc.add(new Field("publisher", "", Store.YES, Index.ANALYZED)); - doc.add(new NumericField("year", Store.YES, true).setIntValue(1990)); - doc.add(new NumericField("gross", Store.YES, true).setDoubleValue(900.00)); - - doc.add(new NumericField("longField", Store.YES, true).setLongValue(1)); - doc.add(new NumericField("shortField", Store.YES, true).setIntValue(1)); - doc.add(new NumericField("byteField", Store.YES, true).setIntValue(1)); - doc.add(new NumericField("floatField", Store.YES, true).setFloatValue(1)); - - return doc; - } - - @Before - public void setUp() throws Exception { - serializer = new LuceneSerializer(true, true); - entityPath = new PathBuilder(Object.class, "obj"); - title = entityPath.getString("title"); - author = entityPath.getString("author"); - text = entityPath.getString("text"); - publisher = entityPath.getString("publisher"); - year = entityPath.getNumber("year", Integer.class); - rating = entityPath.getString("rating"); - gross = entityPath.getNumber("gross", Double.class); - titles = entityPath.getCollection("title", String.class, StringPath.class); - - longField = entityPath.getNumber("longField", Long.class); - shortField = entityPath.getNumber("shortField", Short.class); - byteField = entityPath.getNumber("byteField", Byte.class); - floatField = entityPath.getNumber("floatField", Float.class); - - idx = new RAMDirectory(); - config = - new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_30)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument()); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @After - public void tearDown() throws Exception { - searcher.close(); - } - - private void testQuery(Expression expr, int expectedHits) throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - } - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - @Test - public void queryElement() throws Exception { - Query query1 = serializer.toQuery(author.like("Michael"), metadata); - Query query2 = serializer.toQuery(text.like("Text"), metadata); - - BooleanExpression query = Expressions.anyOf(new QueryElement(query1), new QueryElement(query2)); - testQuery(query, "author:michael text:text", 1); - } - - @Test - public void like() throws Exception { - testQuery(author.like("*ichael*"), "author:*ichael*", 1); - } - - @Test - public void like_custom_wildcard_single_character() throws Exception { - testQuery(author.like("Mi?hael"), "author:mi?hael", 1); - } - - @Test - public void like_custom_wildcard_multiple_character() throws Exception { - testQuery(text.like("*U*X*"), "text:*u*x*", 1); - } - - @Test - public void like_phrase() throws Exception { - testQuery(title.like("*rassic Par*"), "+title:**rassic* +title:*par**", 1); - } - - @Test - public void like_or_like() throws Exception { - testQuery(title.like("House").or(author.like("*ichae*")), "title:house author:*ichae*", 1); - } - - @Test - public void like_and_like() throws Exception { - testQuery(title.like("*assic*").and(rating.like("G?od")), "+title:*assic* +rating:g?od", 1); - } - - @Test - public void eq() throws Exception { - testQuery(rating.eq("good"), "rating:good", 1); - } - - @Test - public void eq_with_deep_path() throws Exception { - StringPath deepPath = entityPath.get("property1", Object.class).getString("property2"); - testQuery(deepPath.eq("good"), "property1.property2:good", 0); - } - - @Test - public void fuzzyLike() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good"), "rating:Good~0.5", 1); - } - - @Test - public void fuzzyLike_with_similarity() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 0.6f), "rating:Good~0.6", 1); - } - - @Test - public void fuzzyLike_with_similarity_and_prefix() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 0.6f, 0), "rating:Good~0.6", 1); - } - - @Test - public void eq_numeric_integer() throws Exception { - testQuery(year.eq(1990), "year:" + YEAR_PREFIX_CODED, 1); - } - - @Test - public void eq_numeric_double() throws Exception { - testQuery(gross.eq(900.00), "gross:" + GROSS_PREFIX_CODED, 1); - } - - @Test - public void eq_numeric() throws Exception { - testQuery(longField.eq(1L), "longField:" + LONG_PREFIX_CODED, 1); - testQuery(shortField.eq((short) 1), "shortField:" + SHORT_PREFIX_CODED, 1); - testQuery(byteField.eq((byte) 1), "byteField:" + BYTE_PREFIX_CODED, 1); - testQuery(floatField.eq((float) 1.0), "floatField:" + FLOAT_PREFIX_CODED, 1); - } - - @Test - public void equals_ignores_case() throws Exception { - testQuery(title.eq("Jurassic"), "title:jurassic", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_or_year_equals() throws Exception { - testQuery( - title.equalsIgnoreCase("House").or(year.eq(1990)), - "title:house year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - public void eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)), - "+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - public void eq_and_eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)).and(author.eq("Michael Crichton")), - "+(+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED + ") +author:\"michael crichton\"", - 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_ignore_case_and_or() throws Exception { - testQuery( - title - .equalsIgnoreCase("Jurassic Park") - .and(rating.equalsIgnoreCase("Bad")) - .or(author.equalsIgnoreCase("Michael Crichton")), - "(+title:\"jurassic park\" +rating:bad) author:\"michael crichton\"", - 1); - } - - @Test - public void eq_or_eq_and_eq_does_not_find_results() throws Exception { - testQuery( - title.eq("jeeves").or(rating.eq("superb")).and(author.eq("michael crichton")), - "+(title:jeeves rating:superb) +author:\"michael crichton\"", - 0); - } - - @Test - public void eq_phrase() throws Exception { - testQuery(title.eq("Jurassic Park"), "title:\"jurassic park\"", 1); - } - - @Test - @Ignore("Not easily done in Lucene!") - public void publisher_equals_empty_string() throws Exception { - testQuery(publisher.eq(""), "publisher:", 1); - } - - @Test - public void eq_phrase_should_not_find_results_but_luceNe_semantics_differs_from_querydsls() - throws Exception { - testQuery(text.eq("UNIX System"), "text:\"unix system\"", 1); - } - - @Test - public void eq_phrase_does_not_find_results_because_word_in_middle() throws Exception { - testQuery(title.eq("Jurassic Amusement Park"), "title:\"jurassic amusement park\"", 0); - } - - @Test - public void like_not_does_not_find_results() throws Exception { - testQuery(title.like("*H*e*").not(), "-title:*h*e* +*:*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_negation_or_rating_equals_ignore_case() throws Exception { - testQuery( - title.equalsIgnoreCase("House").not().or(rating.equalsIgnoreCase("Good")), - "-title:house rating:good", - 1); - } - - @Test - public void eq_not_does_not_find_results() throws Exception { - testQuery(title.eq("Jurassic Park").not(), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void title_equals_not_house() throws Exception { - testQuery(title.eq("house").not(), "-title:house +*:*", 1); - } - - @Test - public void eq_and_eq_not_does_not_find_results_because_second_expression_finds_nothing() - throws Exception { - testQuery( - rating.eq("superb").and(title.eq("house").not()), "+rating:superb +(-title:house +*:*)", 0); - } - - @Test - public void not_equals_finds_one() throws Exception { - testQuery(title.ne("house"), "-title:house +*:*", 1); - } - - @Test - public void not_equals_finds_none() throws Exception { - testQuery(title.ne("Jurassic Park"), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void nothing_found_with_not_equals_or_equals() throws Exception { - testQuery( - title.ne("jurassic park").or(rating.eq("lousy")), - "(-title:\"jurassic park\" +*:*) rating:lousy", - 0); - } - - @Test - public void ne_and_eq() throws Exception { - testQuery(title.ne("house").and(rating.eq("good")), "+(-title:house +*:*) +rating:good", 1); - } - - @Test - public void startsWith() throws Exception { - testQuery(title.startsWith("Jurassi"), "title:jurassi*", 1); - } - - @Test - public void startsWith_phrase() throws Exception { - testQuery(title.startsWith("jurassic par"), "+title:jurassic* +title:*par*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void starts_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.startsWithIgnoreCase("urassic Par"), "+title:urassic* +title:*par*", 0); - } - - @Test - public void endsWith() throws Exception { - testQuery(title.endsWith("ark"), "title:*ark", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Park"), "+title:*sic* +title:*park", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Par"), "+title:*sic* +title:*par", 0); - } - - @Test - public void contains() throws Exception { - testQuery(title.contains("rassi"), "title:*rassi*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void contains_ignore_case_phrase() throws Exception { - testQuery(title.containsIgnoreCase("rassi Pa"), "+title:*rassi* +title:*pa*", 1); - } - - @Test - public void contains_user_inputted_wildcards_dont_work() throws Exception { - testQuery(title.contains("r*i"), "title:*r\\*i*", 0); - } - - @Test - public void between() throws Exception { - testQuery(title.between("Indiana", "Kundun"), "title:[indiana TO kundun]", 1); - } - - @Test - public void between_numeric_integer() throws Exception { - testQuery(year.between(1980, 2000), "year:[1980 TO 2000]", 1); - } - - @Test - public void between_numeric_double() throws Exception { - testQuery(gross.between(10.00, 19030.00), "gross:[10.0 TO 19030.0]", 1); - } - - @Test - public void between_numeric() throws Exception { - testQuery(longField.between(0L, 2L), "longField:[0 TO 2]", 1); - testQuery(shortField.between((short) 0, (short) 2), "shortField:[0 TO 2]", 1); - testQuery(byteField.between((byte) 0, (byte) 2), "byteField:[0 TO 2]", 1); - testQuery(floatField.between((float) 0.0, (float) 2.0), "floatField:[0.0 TO 2.0]", 1); - } - - @Test - public void between_is_inclusive_from_start() throws Exception { - testQuery(title.between("Jurassic", "Kundun"), "title:[jurassic TO kundun]", 1); - } - - @Test - public void between_is_inclusive_to_end() throws Exception { - testQuery(title.between("Indiana", "Jurassic"), "title:[indiana TO jurassic]", 1); - } - - @Test - public void between_does_not_find_results() throws Exception { - testQuery(title.between("Indiana", "Jurassib"), "title:[indiana TO jurassib]", 0); - } - - @Test - public void in() throws Exception { - testQuery(title.in(Arrays.asList("jurassic", "park")), "title:jurassic title:park", 1); - testQuery(title.in("jurassic", "park"), "title:jurassic title:park", 1); - testQuery(title.eq("jurassic").or(title.eq("park")), "title:jurassic title:park", 1); - } - - @Test - public void lt() throws Exception { - testQuery(rating.lt("Superb"), "rating:{* TO superb}", 1); - } - - @Test - public void lt_numeric_integer() throws Exception { - testQuery(year.lt(1991), "year:{* TO 1991}", 1); - } - - @Test - public void lt_numeric_double() throws Exception { - testQuery(gross.lt(10000.0), "gross:{* TO 10000.0}", 1); - } - - @Test - public void lt_not_in_range_because_equal() throws Exception { - testQuery(rating.lt("Good"), "rating:{* TO good}", 0); - } - - @Test - public void lt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.lt(1990), "year:{* TO 1990}", 0); - } - - @Test - public void lt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.lt(900.0), "gross:{* TO 900.0}", 0); - } - - @Test - public void loe() throws Exception { - testQuery(rating.loe("Superb"), "rating:[* TO superb]", 1); - } - - @Test - public void loe_numeric_integer() throws Exception { - testQuery(year.loe(1991), "year:[* TO 1991]", 1); - } - - @Test - public void loe_numeric_double() throws Exception { - testQuery(gross.loe(903.0), "gross:[* TO 903.0]", 1); - } - - @Test - public void loe_equal() throws Exception { - testQuery(rating.loe("Good"), "rating:[* TO good]", 1); - } - - @Test - public void loe_numeric_integer_equal() throws Exception { - testQuery(year.loe(1990), "year:[* TO 1990]", 1); - } - - @Test - public void loe_numeric_double_equal() throws Exception { - testQuery(gross.loe(900.0), "gross:[* TO 900.0]", 1); - } - - @Test - public void loe_not_found() throws Exception { - testQuery(rating.loe("Bad"), "rating:[* TO bad]", 0); - } - - @Test - public void loe_numeric_integer_not_found() throws Exception { - testQuery(year.loe(1989), "year:[* TO 1989]", 0); - } - - @Test - public void loe_numeric_double_not_found() throws Exception { - testQuery(gross.loe(899.9), "gross:[* TO 899.9]", 0); - } - - @Test - public void gt() throws Exception { - testQuery(rating.gt("Bad"), "rating:{bad TO *}", 1); - } - - @Test - public void gt_numeric_integer() throws Exception { - testQuery(year.gt(1989), "year:{1989 TO *}", 1); - } - - @Test - public void gt_numeric_double() throws Exception { - testQuery(gross.gt(100.00), "gross:{100.0 TO *}", 1); - } - - @Test - public void gt_not_in_range_because_equal() throws Exception { - testQuery(rating.gt("Good"), "rating:{good TO *}", 0); - } - - @Test - public void gt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.gt(1990), "year:{1990 TO *}", 0); - } - - @Test - public void gt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.gt(900.00), "gross:{900.0 TO *}", 0); - } - - @Test - public void goe() throws Exception { - testQuery(rating.goe("Bad"), "rating:[bad TO *]", 1); - } - - @Test - public void goe_numeric_integer() throws Exception { - testQuery(year.goe(1989), "year:[1989 TO *]", 1); - } - - @Test - public void goe_numeric_double() throws Exception { - testQuery(gross.goe(320.50), "gross:[320.5 TO *]", 1); - } - - @Test - public void goe_equal() throws Exception { - testQuery(rating.goe("Good"), "rating:[good TO *]", 1); - } - - @Test - public void goe_numeric_integer_equal() throws Exception { - testQuery(year.goe(1990), "year:[1990 TO *]", 1); - } - - @Test - public void goe_numeric_double_equal() throws Exception { - testQuery(gross.goe(900.00), "gross:[900.0 TO *]", 1); - } - - @Test - public void goe_not_found() throws Exception { - testQuery(rating.goe("Hood"), "rating:[hood TO *]", 0); - } - - @Test - public void goe_numeric_integer_not_found() throws Exception { - testQuery(year.goe(1991), "year:[1991 TO *]", 0); - } - - @Test - public void goe_numeric_double_not_found() throws Exception { - testQuery(gross.goe(900.10), "gross:[900.1 TO *]", 0); - } - - @Test - public void equals_empty_string() throws Exception { - testQuery(title.eq(""), "title:", 0); - } - - @Test - public void not_equals_empty_string() throws Exception { - testQuery(title.ne(""), "-title: +*:*", 1); - } - - @Test - public void contains_empty_string() throws Exception { - testQuery(title.contains(""), "title:**", 1); - } - - @Test - public void like_empty_string() throws Exception { - testQuery(title.like(""), "title:", 0); - } - - @Test - public void starts_with_empty_string() throws Exception { - testQuery(title.startsWith(""), "title:*", 1); - } - - @Test - public void ends_with_empty_string() throws Exception { - testQuery(title.endsWith(""), "title:*", 1); - } - - @Test - public void between_empty_strings() throws Exception { - testQuery(title.between("", ""), "title:[ TO ]", 0); - } - - @Test - public void booleanBuilder() throws Exception { - testQuery(new BooleanBuilder(gross.goe(900.10)), "gross:[900.1 TO *]", 0); - } - - @Test - @Ignore - public void fuzzy() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void proximity() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void boost() throws Exception { - fail("Not yet implemented!"); - } - - @Test - public void pathAny() throws Exception { - testQuery(titles.any().eq("Jurassic"), "title:jurassic", 1); - } - - private boolean unsupportedOperation(Predicate filter) { - return UNSUPPORTED_OPERATORS.contains(((Operation) filter).getOperator()); - } - - @Test - public void various() throws Exception { - MatchingFiltersFactory filters = - new MatchingFiltersFactory(QuerydslModule.LUCENE, Target.LUCENE); - for (Predicate filter : filters.string(title, StringConstant.create("jurassic park"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(author, StringConstant.create("michael crichton"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(title, StringConstant.create("1990"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 0); - } - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/Person.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/Person.java deleted file mode 100644 index 98b5b9091b..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/Person.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.annotations.QueryEntity; -import java.time.LocalDate; - -@QueryEntity -public class Person { - private final String id; - private final String name; - private final LocalDate birthDate; - - public Person(String id, String name, LocalDate birthDate) { - this.id = id; - this.name = name; - this.birthDate = birthDate; - } - - public String getId() { - return id; - } - - public LocalDate getBirthDate() { - return birthDate; - } - - public String getName() { - return name; - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/PhraseElementTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/PhraseElementTest.java deleted file mode 100644 index 0fa6f92014..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/PhraseElementTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class PhraseElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, false); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:Hello World"); - assertThat(serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - } - - @Test - public void equals() { - PhraseElement el1 = new PhraseElement("x"), - el2 = new PhraseElement("x"), - el3 = new PhraseElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - } - - @Test - public void hashCode_() { - PhraseElement el1 = new PhraseElement("x"), el2 = new PhraseElement("x"); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QDocument.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QDocument.java deleted file mode 100644 index 84c11ce8fc..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QDocument.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import com.querydsl.core.types.PathMetadataFactory; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import org.apache.lucene.document.Document; - -public class QDocument extends EntityPathBase { - - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(final String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final NumberPath year = createNumber("year", Integer.class); - - public final StringPath title = createString("title"); - - public final NumberPath gross = createNumber("gross", Double.class); -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QueryElementTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QueryElementTest.java deleted file mode 100644 index 74ede9c968..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/QueryElementTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.lucene.index.Term; -import org.apache.lucene.search.TermQuery; -import org.junit.Ignore; -import org.junit.Test; - -public class QueryElementTest { - - @Test - @Ignore - public void test() { - QueryElement element = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element.toString()).isEqualTo("str:text"); - // assertEquals(element.getQuery().hashCode(), element.hashCode()); - - QueryElement element2 = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element).isEqualTo(element2); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/TermElementTest.java b/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/TermElementTest.java deleted file mode 100644 index ca879526a7..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/java/com/querydsl/lucene3/TermElementTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene3; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class TermElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, true); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - assertThat(serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString()) - .isEqualTo("title:Hello World"); - } - - @Test - public void testEqualsAndHashCode() { - TermElement el1 = new TermElement("x"), el2 = new TermElement("x"), el3 = new TermElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene3/src/test/resources/log4j.properties.example b/querydsl-libraries/querydsl-lucene3/src/test/resources/log4j.properties.example deleted file mode 100644 index 0c3a1143dc..0000000000 --- a/querydsl-libraries/querydsl-lucene3/src/test/resources/log4j.properties.example +++ /dev/null @@ -1,9 +0,0 @@ -# Configure an appender that logs to console -log4j.rootLogger=info, A1 -log4j.threshold=debug -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c{1} - %m%n - -# Configuration of logging levels for different packages -log4j.logger.com.querydsl.lucene3=DEBUG diff --git a/querydsl-libraries/querydsl-lucene4/README.md b/querydsl-libraries/querydsl-lucene4/README.md deleted file mode 100644 index 60e5c75742..0000000000 --- a/querydsl-libraries/querydsl-lucene4/README.md +++ /dev/null @@ -1,57 +0,0 @@ -## Querydsl Lucene 4 - -The Lucene module provides integration with the Lucene 4 indexing library. - -**Maven integration** - - Add the following dependencies to your Maven project : -```XML - - io.github.openfeign.querydsl - querydsl-lucene4 - ${querydsl.version} - -``` - -**Creating the query types** - -With fields year and title a manually created query type could look something like this: - -```JAVA -public class QDocument extends EntityPathBase{ - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final StringPath year = createString("year"); - - public final StringPath title = createString("title"); -} -``` - -QDocument represents a Lucene document with the fields year and title. - -Code generation is not available for Lucene, since no schema data is available. - -**Querying** - -Querying with Querydsl Lucene is as simple as this: - -```JAVA -QDocument doc = new QDocument("doc"); - -IndexSearcher searcher = new IndexSearcher(index); -LuceneQuery query = new LuceneQuery(true, searcher); -List documents = query - .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle")) - .fetch(); -``` - -which is transformed into the following Lucene query : -``` -+year:[1800 TO 2000] +title:huckle* -``` - -For more information on the Querydsl Lucene module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s05.html diff --git a/querydsl-libraries/querydsl-lucene4/pom.xml b/querydsl-libraries/querydsl-lucene4/pom.xml deleted file mode 100644 index 257682d532..0000000000 --- a/querydsl-libraries/querydsl-lucene4/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - - - io.github.openfeign.querydsl - querydsl-libraries - 6.0-SNAPSHOT - - - querydsl-lucene4 - Querydsl - Lucene 4 support - Lucene support for Querydsl - - - 4.10.4 - org.apache.lucene.*;version="[4,5)", - ${osgi.import.package.root} - - - - - org.jetbrains - annotations - provided - - - org.apache.lucene - lucene-core - ${lucene.version} - provided - - - org.apache.lucene - lucene-analyzers-common - ${lucene.version} - provided - - - org.apache.lucene - lucene-queryparser - ${lucene.version} - provided - - - org.apache.lucene - lucene-queries - ${lucene.version} - provided - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - - - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - test-jar - test - - - - io.github.openfeign.querydsl - querydsl-apt - ${project.version} - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - com.querydsl.lucene4 - - - - - - - org.apache.felix - maven-bundle-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - - com.querydsl.apt.QuerydslAnnotationProcessor - - - - - - diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/AbstractLuceneQuery.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/AbstractLuceneQuery.java deleted file mode 100644 index 9f409722ad..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/AbstractLuceneQuery.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.EmptyCloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.Fetchable; -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.SimpleQuery; -import com.querydsl.core.support.QueryMixin; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.ParamExpression; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.Predicate; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.queries.ChainedFilter; -import org.apache.lucene.sandbox.queries.DuplicateFilter; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TotalHitCountCollector; -import org.jetbrains.annotations.Nullable; - -/** - * AbstractLuceneQuery is an abstract super class for Lucene query implementations - * - * @author tiwe - * @param projection type - * @param concrete subtype of querydsl - */ -public abstract class AbstractLuceneQuery> - implements SimpleQuery, Fetchable { - - private static final String JAVA_ISO_CONTROL = "[\\p{Cntrl}&&[^\r\n\t]]"; - - private final QueryMixin queryMixin; - - private final IndexSearcher searcher; - - private final LuceneSerializer serializer; - - private final Function transformer; - - @Nullable private Set fieldsToLoad; - - private List filters = Collections.emptyList(); - - @Nullable private Filter filter; - - @Nullable private Sort querySort; - - @SuppressWarnings("unchecked") - public AbstractLuceneQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - queryMixin = new QueryMixin((Q) this, new DefaultQueryMetadata()); - this.serializer = serializer; - this.searcher = searcher; - this.transformer = transformer; - } - - public AbstractLuceneQuery(IndexSearcher searcher, Function transformer) { - this(LuceneSerializer.DEFAULT, searcher, transformer); - } - - private long innerCount() { - try { - final int maxDoc = searcher.getIndexReader().maxDoc(); - if (maxDoc == 0) { - return 0; - } - TotalHitCountCollector collector = new TotalHitCountCollector(); - searcher.search(createQuery(), getFilter(), collector); - return collector.getTotalHits(); - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public long fetchCount() { - return innerCount(); - } - - protected Query createQuery() { - if (queryMixin.getMetadata().getWhere() == null) { - return new MatchAllDocsQuery(); - } - return serializer.toQuery(queryMixin.getMetadata().getWhere(), queryMixin.getMetadata()); - } - - /** - * Create a filter for constraints defined in this querydsl - * - * @return filter - */ - public Filter asFilter() { - return new QueryWrapperFilter(createQuery()); - } - - @Override - public Q distinct() { - throw new UnsupportedOperationException("use distinct(path) instead"); - } - - /** - * Add a DuplicateFilter for the field of the given property path - * - * @param property distinct property - * @return the current object - */ - public Q distinct(Path property) { - return filter(new DuplicateFilter(serializer.toField(property))); - } - - /** - * Apply the given Lucene filter to the search results - * - * @param filter filter - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q filter(Filter filter) { - if (filters.isEmpty()) { - this.filter = filter; - filters = Collections.singletonList(filter); - } else { - this.filter = null; - if (filters.size() == 1) { - filters = new ArrayList(); - } - filters.add(filter); - } - return (Q) this; - } - - private Filter getFilter() { - if (filter == null && !filters.isEmpty()) { - filter = new ChainedFilter(filters.toArray(new Filter[0])); - } - return filter; - } - - @Override - public Q limit(long limit) { - return queryMixin.limit(limit); - } - - @Override - public CloseableIterator iterate() { - final QueryMetadata metadata = queryMixin.getMetadata(); - final List> orderBys = metadata.getOrderBy(); - final Integer queryLimit = metadata.getModifiers().getLimitAsInteger(); - final Integer queryOffset = metadata.getModifiers().getOffsetAsInteger(); - Sort sort = querySort; - int limit; - final int offset = queryOffset != null ? queryOffset : 0; - try { - limit = maxDoc(); - if (limit == 0) { - return new EmptyCloseableIterator(); - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - if (queryLimit != null && queryLimit < limit) { - limit = queryLimit; - } - if (sort == null && !orderBys.isEmpty()) { - sort = serializer.toSort(orderBys); - } - - try { - ScoreDoc[] scoreDocs; - int sumOfLimitAndOffset = limit + offset; - if (sumOfLimitAndOffset < 1) { - throw new QueryException( - "The given limit (" - + limit - + ") and offset (" - + offset - + ") cause an integer overflow."); - } - if (sort != null) { - scoreDocs = - searcher.search(createQuery(), getFilter(), sumOfLimitAndOffset, sort, false, false) - .scoreDocs; - } else { - scoreDocs = - searcher.search( - createQuery(), getFilter(), sumOfLimitAndOffset, Sort.INDEXORDER, false, false) - .scoreDocs; - } - if (offset < scoreDocs.length) { - return new ResultIterator(scoreDocs, offset, searcher, fieldsToLoad, transformer); - } - return new EmptyCloseableIterator(); - } catch (final IOException e) { - throw new QueryException(e); - } - } - - private List innerList() { - return new IteratorAdapter(iterate()).asList(); - } - - @Override - public List fetch() { - return innerList(); - } - - /** - * Set the given fields to load - * - * @param fieldsToLoad fields to load - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(Set fieldsToLoad) { - this.fieldsToLoad = fieldsToLoad; - return (Q) this; - } - - /** - * Load only the fields of the given paths - * - * @param paths fields to load - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(Path... paths) { - Set fields = new HashSet(); - for (Path path : paths) { - fields.add(serializer.toField(path)); - } - this.fieldsToLoad = fields; - return (Q) this; - } - - @Override - public QueryResults fetchResults() { - List documents = innerList(); - /* - * TODO Get rid of fetchCount(). It could be implemented by iterating the - * fetch results in fetch* from n to m. - */ - return new QueryResults(documents, queryMixin.getMetadata().getModifiers(), innerCount()); - } - - @Override - public Q offset(long offset) { - return queryMixin.offset(offset); - } - - public Q orderBy(OrderSpecifier o) { - return queryMixin.orderBy(o); - } - - @Override - public Q orderBy(OrderSpecifier... o) { - return queryMixin.orderBy(o); - } - - @Override - public Q restrict(QueryModifiers modifiers) { - return queryMixin.restrict(modifiers); - } - - @Override - public

Q set(ParamExpression

param, P value) { - return queryMixin.set(param, value); - } - - @SuppressWarnings("unchecked") - public Q sort(Sort sort) { - this.querySort = sort; - return (Q) this; - } - - @Nullable - private T oneResult(boolean unique) { - try { - int maxDoc = maxDoc(); - if (maxDoc == 0) { - return null; - } - final ScoreDoc[] scoreDocs = - searcher.search(createQuery(), getFilter(), maxDoc, Sort.INDEXORDER, false, false) - .scoreDocs; - int index = 0; - QueryModifiers modifiers = queryMixin.getMetadata().getModifiers(); - Long offset = modifiers.getOffset(); - if (offset != null) { - index = offset.intValue(); - } - Long limit = modifiers.getLimit(); - if (unique - && (limit == null ? scoreDocs.length - index > 1 : limit > 1 && scoreDocs.length > 1)) { - throw new NonUniqueResultException( - "Unique result requested, but " + scoreDocs.length + " found."); - } else if (scoreDocs.length > index) { - Document document; - if (fieldsToLoad != null) { - document = searcher.doc(scoreDocs[index].doc, fieldsToLoad); - } else { - document = searcher.doc(scoreDocs[index].doc); - } - return transformer.apply(document); - } else { - return null; - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public T fetchFirst() { - return oneResult(false); - } - - @Override - public T fetchOne() throws NonUniqueResultException { - return oneResult(true); - } - - public Q where(Predicate e) { - return queryMixin.where(e); - } - - @Override - public Q where(Predicate... e) { - return queryMixin.where(e); - } - - @Override - public String toString() { - return createQuery().toString().replaceAll(JAVA_ISO_CONTROL, "_"); - } - - private int maxDoc() throws IOException { - return searcher.getIndexReader().maxDoc(); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/IgnoreCaseUnsupportedException.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/IgnoreCaseUnsupportedException.java deleted file mode 100644 index 6a33cff01f..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/IgnoreCaseUnsupportedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -/** - * Thrown for case ignore usage - * - * @author tiwe - */ -public class IgnoreCaseUnsupportedException extends UnsupportedOperationException { - - private static final long serialVersionUID = 412913389929530788L; - - public IgnoreCaseUnsupportedException() { - super("Ignore case queries are not supported with Lucene"); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneExpressions.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneExpressions.java deleted file mode 100644 index e8054f82a0..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneExpressions.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.BooleanExpression; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.util.automaton.LevenshteinAutomata; - -/** - * Utility methods to create filter expressions for Lucene queries that are not covered by the - * Querydsl standard expression model - * - * @author tiwe - */ -public final class LuceneExpressions { - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @return condition - */ - public static BooleanExpression fuzzyLike(Path path, String value) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param maxEdits must be >= 0 and <= {@link - * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}. - * @return condition - */ - public static BooleanExpression fuzzyLike(Path path, String value, int maxEdits) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, maxEdits)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param maxEdits must be >= 0 and <= {@link - * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}. - * @param prefixLength length of common (non-fuzzy) prefix - * @return condition - */ - public static BooleanExpression fuzzyLike( - Path path, String value, int maxEdits, int prefixLength) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, maxEdits, prefixLength)); - } - - private LuceneExpressions() {} -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneOps.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneOps.java deleted file mode 100644 index d11f3d01a5..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneOps.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.Operator; - -/** - * Lucene specific operators - * - * @author tiwe - */ -public enum LuceneOps implements Operator { - LUCENE_QUERY(Object.class), - PHRASE(String.class), - TERM(String.class); - - private final Class type; - - LuceneOps(Class type) { - this.type = type; - } - - @Override - public Class getType() { - return type; - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneQuery.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneQuery.java deleted file mode 100644 index 5e9ad57d1c..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneQuery.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code LuceneQuery} is a Querydsl query implementation for Lucene queries. - * - *

Example: - * - *

{@code
- * QDocument doc = new QDocument("doc");
- *
- * IndexSearcher searcher = new IndexSearcher(index);
- * LuceneQuery query = new LuceneQuery(true, searcher);
- * List documents = query
- *     .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- *     .fetch();
- * }
- * - * @author vema - */ -public class LuceneQuery extends AbstractLuceneQuery { - - private static final Function TRANSFORMER = - new Function() { - @Override - public Document apply(Document input) { - return input; - } - }; - - public LuceneQuery(IndexSearcher searcher) { - super(searcher, TRANSFORMER); - } - - public LuceneQuery(LuceneSerializer luceneSerializer, IndexSearcher searcher) { - super(luceneSerializer, searcher, TRANSFORMER); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneSerializer.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneSerializer.java deleted file mode 100644 index 8fe0919519..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneSerializer.java +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.*; -import org.apache.lucene.index.Term; -import org.apache.lucene.queryparser.classic.QueryParser; -import org.apache.lucene.search.*; -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.BytesRefBuilder; -import org.apache.lucene.util.NumericUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Serializes Querydsl queries to Lucene queries. - * - * @author vema - */ -public class LuceneSerializer { - private static final Map, SortField.Type> sortFields = - new HashMap, SortField.Type>(); - - static { - sortFields.put(Integer.class, SortField.Type.INT); - sortFields.put(Float.class, SortField.Type.FLOAT); - sortFields.put(Long.class, SortField.Type.LONG); - sortFields.put(Double.class, SortField.Type.DOUBLE); - sortFields.put(Short.class, SortField.Type.SHORT); - sortFields.put(Byte.class, SortField.Type.BYTE); - sortFields.put(BigDecimal.class, SortField.Type.DOUBLE); - sortFields.put(BigInteger.class, SortField.Type.LONG); - } - - public static final LuceneSerializer DEFAULT = new LuceneSerializer(false, true); - - private final boolean lowerCase; - - private final boolean splitTerms; - - private final Locale sortLocale; - - public LuceneSerializer(boolean lowerCase, boolean splitTerms) { - this(lowerCase, splitTerms, Locale.getDefault()); - } - - public LuceneSerializer(boolean lowerCase, boolean splitTerms, Locale sortLocale) { - this.lowerCase = lowerCase; - this.splitTerms = splitTerms; - this.sortLocale = sortLocale; - } - - private Query toQuery(Operation operation, QueryMetadata metadata) { - Operator op = operation.getOperator(); - if (op == Ops.OR) { - return toTwoHandSidedQuery(operation, Occur.SHOULD, metadata); - } else if (op == Ops.AND) { - return toTwoHandSidedQuery(operation, Occur.MUST, metadata); - } else if (op == Ops.NOT) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(toQuery(operation.getArg(0), metadata), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } else if (op == Ops.LIKE) { - return like(operation, metadata); - } else if (op == Ops.LIKE_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.EQ) { - return eq(operation, metadata, false); - } else if (op == Ops.EQ_IGNORE_CASE) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.NE) { - return ne(operation, metadata, false); - } else if (op == Ops.STARTS_WITH) { - return startsWith(metadata, operation, false); - } else if (op == Ops.STARTS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.ENDS_WITH) { - return endsWith(operation, metadata, false); - } else if (op == Ops.ENDS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.STRING_CONTAINS) { - return stringContains(operation, metadata, false); - } else if (op == Ops.STRING_CONTAINS_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.BETWEEN) { - return between(operation, metadata); - } else if (op == Ops.IN) { - return in(operation, metadata, false); - } else if (op == Ops.NOT_IN) { - return notIn(operation, metadata, false); - } else if (op == Ops.LT) { - return lt(operation, metadata); - } else if (op == Ops.GT) { - return gt(operation, metadata); - } else if (op == Ops.LOE) { - return le(operation, metadata); - } else if (op == Ops.GOE) { - return ge(operation, metadata); - } else if (op == LuceneOps.LUCENE_QUERY) { - @SuppressWarnings("unchecked") // this is the expected type - Constant expectedConstant = (Constant) operation.getArg(0); - return expectedConstant.getConstant(); - } - throw new UnsupportedOperationException("Illegal operation " + operation); - } - - private Query toTwoHandSidedQuery(Operation operation, Occur occur, QueryMetadata metadata) { - Query lhs = toQuery(operation.getArg(0), metadata); - Query rhs = toQuery(operation.getArg(1), metadata); - BooleanQuery bq = new BooleanQuery(); - bq.add(createBooleanClause(lhs, occur)); - bq.add(createBooleanClause(rhs, occur)); - return bq; - } - - /** - * If the query is a BooleanQuery and it contains a single Occur.MUST_NOT clause it will be - * returned as is. Otherwise it will be wrapped in a BooleanClause with the given Occur. - */ - private BooleanClause createBooleanClause(Query query, Occur occur) { - if (query instanceof BooleanQuery) { - BooleanClause[] clauses = ((BooleanQuery) query).getClauses(); - if (clauses.length == 1 && clauses[0].getOccur().equals(Occur.MUST_NOT)) { - return clauses[0]; - } - } - return new BooleanClause(query, occur); - } - - protected Query like(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convert(path, operation.getArg(1)); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, terms[0])); - } - - protected Query eq(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - - if (Number.class.isAssignableFrom(operation.getArg(1).getType())) { - @SuppressWarnings("unchecked") // guarded by previous check - Constant rightArg = (Constant) operation.getArg(1); - return new TermQuery(new Term(field, convertNumber(rightArg.getConstant()))); - } - - return eq(field, convert(path, operation.getArg(1), metadata), ignoreCase); - } - - private BytesRef convertNumber(Number number) { - if (Integer.class.isInstance(number) - || Byte.class.isInstance(number) - || Short.class.isInstance(number)) { - BytesRefBuilder bytes = new BytesRefBuilder(); - bytes.setLength(NumericUtils.BUF_SIZE_INT); - NumericUtils.intToPrefixCoded(number.intValue(), 0, bytes); - return bytes.toBytesRef(); - } else if (Double.class.isInstance(number) || BigDecimal.class.isInstance(number)) { - BytesRefBuilder bytes = new BytesRefBuilder(); - bytes.setLength(NumericUtils.BUF_SIZE_LONG); - long l = NumericUtils.doubleToSortableLong(number.doubleValue()); - NumericUtils.longToPrefixCoded(l, 0, bytes); - return bytes.toBytesRef(); - } else if (Long.class.isInstance(number) || BigInteger.class.isInstance(number)) { - BytesRefBuilder bytes = new BytesRefBuilder(); - bytes.setLength(NumericUtils.BUF_SIZE_LONG); - NumericUtils.longToPrefixCoded(number.longValue(), 0, bytes); - return bytes.toBytesRef(); - } else if (Float.class.isInstance(number)) { - BytesRefBuilder bytes = new BytesRefBuilder(); - bytes.setLength(NumericUtils.BUF_SIZE_INT); - int i = NumericUtils.floatToSortableInt(number.floatValue()); - NumericUtils.intToPrefixCoded(i, 0, bytes); - return bytes.toBytesRef(); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + number.getClass().getName()); - } - } - - protected Query eq(String field, String[] terms, boolean ignoreCase) { - if (terms.length > 1) { - PhraseQuery pq = new PhraseQuery(); - for (String s : terms) { - pq.add(new Term(field, s)); - } - return pq; - } - return new TermQuery(new Term(field, terms[0])); - } - - protected Query in(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - Path path = getPath(operation.getArg(0)); - String field = toField(path); - @SuppressWarnings("unchecked") // this is the expected type - Constant> expectedConstant = (Constant>) operation.getArg(1); - Collection values = expectedConstant.getConstant(); - BooleanQuery bq = new BooleanQuery(); - if (Number.class.isAssignableFrom(path.getType())) { - for (Object value : values) { - TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value))); - bq.add(eq, Occur.SHOULD); - } - } else { - for (Object value : values) { - String[] str = convert(path, value); - bq.add(eq(field, str, ignoreCase), Occur.SHOULD); - } - } - return bq; - } - - protected Query notIn(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(in(operation, metadata, false), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query ne(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(eq(operation, metadata, ignoreCase), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query startsWith(QueryMetadata metadata, Operation operation, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == 0 ? terms[i] + "*" : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new PrefixQuery(new Term(field, terms[0])); - } - - protected Query stringContains( - Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0] + "*")); - } - - protected Query endsWith(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == terms.length - 1 ? "*" + terms[i] : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0])); - } - - protected Query between(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - // TODO Phrase not properly supported - return range( - path, toField(path), operation.getArg(1), operation.getArg(2), true, true, metadata); - } - - protected Query lt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), false, false, metadata); - } - - protected Query gt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, false, false, metadata); - } - - protected Query le(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), true, true, metadata); - } - - protected Query ge(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, true, true, metadata); - } - - protected Query range( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - if (min != null && Number.class.isAssignableFrom(min.getType()) - || max != null && Number.class.isAssignableFrom(max.getType())) { - @SuppressWarnings("unchecked") // guarded by previous check - Constant minConstant = (Constant) min; - @SuppressWarnings("unchecked") // guarded by previous check - Constant maxConstant = (Constant) max; - - Class numType = - minConstant != null ? minConstant.getType() : maxConstant.getType(); - // this is not necessarily safe, but compile time checking - // on the user side mandates these types to be interchangeable - @SuppressWarnings("unchecked") - Class unboundedNumType = (Class) numType; - return numericRange( - unboundedNumType, - field, - minConstant == null ? null : minConstant.getConstant(), - maxConstant == null ? null : maxConstant.getConstant(), - minInc, - maxInc); - } - return stringRange(leftHandSide, field, min, max, minInc, maxInc, metadata); - } - - protected NumericRangeQuery numericRange( - Class clazz, - String field, - @Nullable N min, - @Nullable N max, - boolean minInc, - boolean maxInc) { - if (clazz.equals(Integer.class)) { - return NumericRangeQuery.newIntRange(field, (Integer) min, (Integer) max, minInc, maxInc); - } else if (clazz.equals(Double.class)) { - return NumericRangeQuery.newDoubleRange(field, (Double) min, (Double) max, minInc, minInc); - } else if (clazz.equals(Float.class)) { - return NumericRangeQuery.newFloatRange(field, (Float) min, (Float) max, minInc, minInc); - } else if (clazz.equals(Long.class)) { - return NumericRangeQuery.newLongRange(field, (Long) min, (Long) max, minInc, minInc); - } else if (clazz.equals(Byte.class) || clazz.equals(Short.class)) { - return NumericRangeQuery.newIntRange( - field, - min != null ? min.intValue() : null, - max != null ? max.intValue() : null, - minInc, - maxInc); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + clazz.getName()); - } - } - - protected Query stringRange( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - - if (min == null) { - return TermRangeQuery.newStringRange( - field, null, convert(leftHandSide, max, metadata)[0], minInc, maxInc); - } else if (max == null) { - return TermRangeQuery.newStringRange( - field, convert(leftHandSide, min, metadata)[0], null, minInc, maxInc); - } else { - return TermRangeQuery.newStringRange( - field, - convert(leftHandSide, min, metadata)[0], - convert(leftHandSide, max, metadata)[0], - minInc, - maxInc); - } - } - - private Path getPath(Expression leftHandSide) { - if (leftHandSide instanceof Path) { - return (Path) leftHandSide; - } else if (leftHandSide instanceof Operation) { - Operation operation = (Operation) leftHandSide; - if (operation.getOperator() == Ops.LOWER || operation.getOperator() == Ops.UPPER) { - return (Path) operation.getArg(0); - } - } - throw new IllegalArgumentException("Unable to transform " + leftHandSide + " to path"); - } - - /** - * template method, override to customize - * - * @param path path - * @return field name - */ - protected String toField(Path path) { - PathMetadata md = path.getMetadata(); - if (md.getPathType() == PathType.COLLECTION_ANY) { - return toField(md.getParent()); - } else { - String rv = md.getName(); - if (md.getParent() != null) { - Path parent = md.getParent(); - if (parent.getMetadata().getPathType() != PathType.VARIABLE) { - rv = toField(parent) + "." + rv; - } - } - return rv; - } - } - - private void verifyArguments(Operation operation) { - List> arguments = operation.getArgs(); - for (int i = 1; i < arguments.size(); ++i) { - if (!(arguments.get(i) instanceof Constant) - && !(arguments.get(i) instanceof ParamExpression) - && !(arguments.get(i) instanceof PhraseElement) - && !(arguments.get(i) instanceof TermElement)) { - throw new IllegalArgumentException( - "operand was of unsupported type " + arguments.get(i).getClass().getName()); - } - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - if (rightHandSide instanceof Operation) { - Operation operation = (Operation) rightHandSide; - if (operation.getOperator() == LuceneOps.PHRASE) { - return operation.getArg(0).toString().split("\\s+"); - } else if (operation.getOperator() == LuceneOps.TERM) { - return new String[] {operation.getArg(0).toString()}; - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } else if (rightHandSide instanceof ParamExpression) { - Object value = metadata.getParams().get(rightHandSide); - if (value == null) { - throw new ParamNotSetException((ParamExpression) rightHandSide); - } - return convert(leftHandSide, value); - - } else if (rightHandSide instanceof Constant) { - return convert(leftHandSide, ((Constant) rightHandSide).getConstant()); - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert(Path leftHandSide, Object rightHandSide) { - String str = rightHandSide.toString(); - if (lowerCase) { - str = str.toLowerCase(); - } - if (splitTerms) { - if (str.equals("")) { - return new String[] {str}; - } else { - return str.split("\\s+"); - } - } else { - return new String[] {str}; - } - } - - private String[] convertEscaped( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - String[] str = convert(leftHandSide, rightHandSide, metadata); - for (int i = 0; i < str.length; i++) { - str[i] = QueryParser.escape(str[i]); - } - return str; - } - - public Query toQuery(Expression expr, QueryMetadata metadata) { - if (expr instanceof Operation) { - return toQuery((Operation) expr, metadata); - } else { - return toQuery(ExpressionUtils.extract(expr), metadata); - } - } - - public Sort toSort(List> orderBys) { - List sorts = new ArrayList(orderBys.size()); - for (OrderSpecifier order : orderBys) { - if (!(order.getTarget() instanceof Path)) { - throw new IllegalArgumentException("argument was not of type Path."); - } - Class type = order.getTarget().getType(); - boolean reverse = !order.isAscending(); - Path path = getPath(order.getTarget()); - if (Number.class.isAssignableFrom(type)) { - sorts.add(new SortField(toField(path), sortFields.get(type), reverse)); - } else { - sorts.add(new SortField(toField(path), SortField.Type.STRING, reverse)); - } - } - Sort sort = new Sort(); - sort.setSort(sorts.toArray(new SortField[0])); - return sort; - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/PhraseElement.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/PhraseElement.java deleted file mode 100644 index 16a7e8c13b..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/PhraseElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code PhraseElement} represents the embedded String as a phrase - * - * @author tiwe - */ -public class PhraseElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public PhraseElement(String str) { - super(LuceneOps.PHRASE, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/QueryElement.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/QueryElement.java deleted file mode 100644 index 141c8ede51..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/QueryElement.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.BooleanOperation; -import org.apache.lucene.search.Query; - -/** - * {@code QueryElement} wraps a Lucene Query - * - * @author tiwe - */ -public class QueryElement extends BooleanOperation { - - private static final long serialVersionUID = 470868107363840155L; - - public QueryElement(Query query) { - super(LuceneOps.LUCENE_QUERY, ConstantImpl.create(query)); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/ResultIterator.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/ResultIterator.java deleted file mode 100644 index c2b76d06a3..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/ResultIterator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.mysema.commons.lang.CloseableIterator; -import com.querydsl.core.QueryException; -import java.io.IOException; -import java.util.Set; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.ScoreDoc; -import org.jetbrains.annotations.Nullable; - -/** - * {@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results - * - * @author tiwe - * @param - */ -public final class ResultIterator implements CloseableIterator { - - private final ScoreDoc[] scoreDocs; - - private int cursor; - - private final IndexSearcher searcher; - - @Nullable private final Set fieldsToLoad; - - private final Function transformer; - - public ResultIterator( - ScoreDoc[] scoreDocs, - int offset, - IndexSearcher searcher, - @Nullable Set fieldsToLoad, - Function transformer) { - this.scoreDocs = scoreDocs.clone(); - this.cursor = offset; - this.searcher = searcher; - this.fieldsToLoad = fieldsToLoad; - this.transformer = transformer; - } - - @Override - public boolean hasNext() { - return cursor != scoreDocs.length; - } - - @Override - public T next() { - try { - Document document; - if (fieldsToLoad != null) { - document = searcher.doc(scoreDocs[cursor++].doc, fieldsToLoad); - } else { - document = searcher.doc(scoreDocs[cursor++].doc); - } - return transformer.apply(document); - } catch (IOException e) { - throw new QueryException(e); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public void close() {} -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TermElement.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TermElement.java deleted file mode 100644 index edf055d37e..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TermElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code TermElement} represents the embedded String as a term - * - * @author tiwe - */ -public class TermElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public TermElement(String str) { - super(LuceneOps.TERM, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TypedQuery.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TypedQuery.java deleted file mode 100644 index 0809eefe34..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/TypedQuery.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code TypedQuery} is a typed query implementation for Lucene queries. - * - *

Converts Lucene documents to typed results via a constructor supplied transformer - * - * @param result type - * @author laim - * @author tiwe - */ -public class TypedQuery extends AbstractLuceneQuery> { - - /** - * Create a new TypedQuery instance - * - * @param searcher index searcher - * @param transformer transformer to transform Lucene documents to result objects - */ - public TypedQuery(IndexSearcher searcher, Function transformer) { - super(searcher, transformer); - } - - /** - * Create a new TypedQuery instance - * - * @param serializer serializer - * @param searcher index searcher - * @param transformer transformer to transform Lucene documents to result objects - */ - public TypedQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - super(serializer, searcher, transformer); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/package-info.java b/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/package-info.java deleted file mode 100644 index e4fa5fc679..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/main/java/com/querydsl/lucene4/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Lucene 4 support */ -package com.querydsl.lucene4; diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneQueryTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneQueryTest.java deleted file mode 100644 index ac02ce1acf..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneQueryTest.java +++ /dev/null @@ -1,747 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.easymock.EasyMock.*; - -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.types.ParamNotSetException; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.Param; -import com.querydsl.core.types.dsl.StringPath; -import java.io.IOException; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.*; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.sandbox.queries.DuplicateFilter; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Sort; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneQuery - * - * @author vema - */ -public class LuceneQueryTest { - - private LuceneQuery query; - private StringPath title; - private NumberPath year; - private NumberPath gross; - - private final StringPath sort = Expressions.stringPath("sort"); - - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - - private Document createDocument( - final String docTitle, - final String docAuthor, - final String docText, - final int docYear, - final double docGross) { - final Document doc = new Document(); - - doc.add(new TextField("title", docTitle, Store.YES)); - doc.add(new TextField("author", docAuthor, Store.YES)); - doc.add(new TextField("text", docText, Store.YES)); - doc.add(new IntField("year", docYear, Store.YES)); - doc.add(new DoubleField("gross", docGross, Store.YES)); - - return doc; - } - - @Before - public void setUp() throws Exception { - final QDocument entityPath = new QDocument("doc"); - title = entityPath.title; - year = entityPath.year; - gross = entityPath.gross; - - idx = new RAMDirectory(); - writer = createWriter(idx); - - writer.addDocument( - createDocument( - "Jurassic Park", "Michael Crichton", "It's a UNIX system! I know this!", 1990, 90.00)); - writer.addDocument( - createDocument( - "Nummisuutarit", "Aleksis Kivi", "ESKO. Ja iloitset ja riemuitset?", 1864, 10.00)); - writer.addDocument( - createDocument( - "The Lord of the Rings", - "John R. R. Tolkien", - "One Ring to rule them all, One Ring to find them, One Ring to bring them all and in" - + " the darkness bind them", - 1954, - 89.00)); - writer.addDocument( - createDocument( - "Introduction to Algorithms", - "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein", - "Bubble sort", - 1990, - 30.50)); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - } - - private IndexWriter createWriter(RAMDirectory idx) throws Exception { - IndexWriterConfig config = - new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_42)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - return new IndexWriter(idx, config); - } - - @After - public void tearDown() throws Exception { - searcher.getIndexReader().close(); - } - - @Test - public void between() { - assertThat(query.where(year.between(1950, 1990)).fetchCount()).isEqualTo(3); - } - - @Test - public void count_empty_where_clause() { - assertThat(query.fetchCount()).isEqualTo(4); - } - - @Test - public void exists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() > 0).isTrue(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() > 0).isFalse(); - } - - @Test - public void notExists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() == 0).isFalse(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() == 0).isTrue(); - } - - @Test - public void count() { - query.where(title.eq("Jurassic Park")); - assertThat(query.fetchCount()).isEqualTo(1); - } - - @Test(expected = QueryException.class) - @Ignore - public void count_index_problem() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchCount(); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void countDistinct() { - query.where(year.between(1900, 3000)); - assertThat(query.distinct().fetchCount()).isEqualTo(3); - } - - @Test - public void in() { - assertThat(query.where(title.in("Jurassic Park", "Nummisuutarit")).fetchCount()).isEqualTo(2); - } - - @Test - public void in2() { - assertThat(query.where(year.in(1990, 1864)).fetchCount()).isEqualTo(3); - } - - @Test - public void in_toString() { - assertThat(query.where(year.in(1990, 1864)).toString()).isEqualTo("year:`____F year:`____H"); - } - - @Test - public void list_sorted_by_year_ascending() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted() { - query.where(year.between(1800, 2000)); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - @Ignore // FIXME - public void sorted_by_different_locales() throws Exception { - Document d1 = new Document(); - Document d2 = new Document(); - Document d3 = new Document(); - d1.add(new Field("sort", "a\u00c4", Store.YES, Index.NOT_ANALYZED)); - d2.add(new Field("sort", "ab", Store.YES, Index.NOT_ANALYZED)); - d3.add(new Field("sort", "aa", Store.YES, Index.NOT_ANALYZED)); - writer = createWriter(idx); - writer.addDocument(d1); - writer.addDocument(d2); - writer.addDocument(d3); - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.ENGLISH), searcher); - assertThat(query.fetch()).hasSize(3); - List results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results).hasSize(3); - assertThat(results.getFirst().getField("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getField("sort").stringValue()).isEqualTo("a\u00c4"); - assertThat(results.get(2).getField("sort").stringValue()).isEqualTo("ab"); - - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.of("fi", "FI")), searcher); - results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results.getFirst().getField("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getField("sort").stringValue()).isEqualTo("ab"); - assertThat(results.get(2).getField("sort").stringValue()).isEqualTo("a\u00c4"); - } - - @Test - public void list_not_sorted_limit_2() { - query.where(year.between(1800, 2000)); - query.limit(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_by_year_limit_1() { - query.where(year.between(1800, 2000)); - query.limit(1); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(1); - } - - @Test - public void list_not_sorted_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_ascending_by_year_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year_restrict_limit_2_offset_1() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1954"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sort() { - Sort sort = LuceneSerializer.DEFAULT.toSort(Collections.singletonList(year.asc())); - - query.where(year.between(1800, 2000)); - // query.orderBy(year.asc()); - query.sort(sort); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_distinct_property() { - assertThat(query.fetch()).hasSize(4); - assertThat(query.distinct(year).fetch()).hasSize(3); - } - - @Test - public void list_with_filter() { - Filter filter = new DuplicateFilter("year"); - assertThat(query.fetch()).hasSize(4); - assertThat(query.filter(filter).fetch()).hasSize(3); - } - - @Test - public void count_distinct_property() { - assertThat(query.fetchCount()).isEqualTo(4L); - assertThat(query.distinct(year).fetchCount()).isEqualTo(3L); - } - - @Test - public void list_sorted_descending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.get(2).get("year")).isEqualTo("1954"); - assertThat(documents.get(3).get("year")).isEqualTo("1864"); - } - - @Test - public void list_sorted_descending_by_gross() { - query.where(gross.between(0.0, 1000.00)); - query.orderBy(gross.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("gross")).isEqualTo("90.0"); - assertThat(documents.get(1).get("gross")).isEqualTo("89.0"); - assertThat(documents.get(2).get("gross")).isEqualTo("30.5"); - assertThat(documents.get(3).get("gross")).isEqualTo("10.0"); - } - - @Test - public void list_sorted_descending_by_year_and_ascending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Introduction to Algorithms"); - assertThat(documents.get(1).get("title")).isEqualTo("Jurassic Park"); - } - - @Test - public void list_sorted_descending_by_year_and_descending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Jurassic Park"); - assertThat(documents.get(1).get("title")).isEqualTo("Introduction to Algorithms"); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetch(); - verify(searcher); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.orderBy(title.asc()); - query.fetch(); - verify(searcher); - } - - @Test - public void offset() { - assertThat(query.where(title.eq("Jurassic Park")).offset(30).fetch()).isEmpty(); - } - - @Test - public void load_list() { - Document document = query.where(title.ne("")).load(title).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_list_fieldSelector() { - Document document = - query.where(title.ne("")).load(Collections.singleton("title")).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult() { - Document document = query.where(title.ne("")).load(title).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult_fieldSelector() { - Document document = query.where(title.ne("")).load(Collections.singleton("title")).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void singleResult() { - assertThat(query.where(title.ne("")).fetchFirst()).isNotNull(); - } - - @Test - public void single_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchFirst().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void single_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchFirst(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void single_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchFirst()).isNull(); - } - - @Test - public void single_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchFirst().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void single_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchFirst().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test(expected = NonUniqueResultException.class) - public void uniqueResult_contract() { - query.where(title.ne("")).fetchOne(); - } - - @Test - public void unique_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchOne().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void unique_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void unique_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchOne()).isNull(); - } - - @Test - public void unique_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchOne().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void unique_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchOne().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test - public void uniqueResult() { - query.where(title.startsWith("Nummi")); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void uniqueResult_with_param() { - final Param param = new Param(String.class, "title"); - query.set(param, "Nummi"); - query.where(title.startsWith(param)); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test(expected = ParamNotSetException.class) - public void uniqueResult_param_not_set() { - final Param param = new Param(String.class, "title"); - query.where(title.startsWith(param)); - query.fetchOne(); - } - - @Test(expected = QueryException.class) - public void uniqueResult_finds_more_than_one_result() { - query.where(year.eq(1990)); - query.fetchOne(); - } - - @Test - public void uniqueResult_finds_no_results() { - query.where(year.eq(2200)); - assertThat(query.fetchOne()).isNull(); - } - - @Test - @Ignore - public void uniqueResult_finds_no_results_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchOne()).isNull(); - verify(searcher); - } - - @Test(expected = QueryException.class) - @Ignore - public void uniqueResult_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchOne(); - verify(searcher); - } - - @Test - @Ignore - public void count_returns_0_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchCount()).isEqualTo(0); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinct() { - query.where(year.between(1900, 2000).or(title.startsWith("Jura"))); - query.orderBy(year.asc()); - final List documents = query.distinct().fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(3); - } - - @Test - public void listResults() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getResults().get(1).get("year")).isEqualTo("1990"); - assertThat(results.getLimit()).isEqualTo(2); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinctResults() { - query.where(year.between(1800, 2000).or(title.eq("The Lord of the Rings"))); - query.restrict(new QueryModifiers(1L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.distinct().fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getLimit()).isEqualTo(1); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test - public void list_all() { - final List results = - query.where(title.like("*")).orderBy(title.asc(), year.desc()).fetch(); - assertThat(results).hasSize(4); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.fetch(); - } - - @Test - public void list_sorted_ascending_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void iterate() { - query.where(year.between(1800, 2000)); - final Iterator iterator = query.iterate(); - int count = 0; - while (iterator.hasNext()) { - iterator.next(); - ++count; - } - assertThat(count).isEqualTo(4); - } - - @Test - public void all_by_excluding_where() { - assertThat(query.fetch()).hasSize(4); - } - - @Test - public void empty_index_should_return_empty_list() throws Exception { - idx = new RAMDirectory(); - - writer = createWriter(idx); - writer.close(); - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - assertThat(query.fetch()).isEmpty(); - } - - @Test(expected = QueryException.class) - public void - list_results_throws_an_illegal_argument_exception_when_sum_of_limit_and_offset_is_negative() { - query.limit(1).offset(Integer.MAX_VALUE).fetchResults(); - } - - @Test - public void limit_max_value() { - assertThat(query.limit(Long.MAX_VALUE).fetch()).hasSize(4); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerNotTokenizedTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerNotTokenizedTest.java deleted file mode 100644 index 4f5ac8c122..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerNotTokenizedTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static com.querydsl.lucene4.QPerson.person; -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import java.time.LocalDate; -import java.util.Arrays; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; -import org.junit.Before; -import org.junit.Test; - -public class LuceneSerializerNotTokenizedTest { - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - private LuceneSerializer serializer; - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private final Person clooney = new Person("actor_1", "George Clooney", LocalDate.of(1961, 4, 6)); - private final Person pitt = new Person("actor_2", "Brad Pitt", LocalDate.of(1963, 12, 18)); - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - private Document createDocument(Person person) { - Document doc = new Document(); - doc.add(new Field("id", person.getId(), Store.YES, Index.NOT_ANALYZED)); - doc.add(new Field("name", person.getName(), Store.YES, Index.NOT_ANALYZED)); - doc.add( - new Field("birthDate", person.getBirthDate().toString(), Store.YES, Index.NOT_ANALYZED)); - return doc; - } - - @Before - public void before() throws Exception { - serializer = new LuceneSerializer(false, false); - idx = new RAMDirectory(); - IndexWriterConfig config = - new IndexWriterConfig(Version.LUCENE_31, new StandardAnalyzer(Version.LUCENE_30)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument(clooney)); - writer.addDocument(createDocument(pitt)); - - Document document = new Document(); - for (String movie : Arrays.asList("Interview with the Vampire", "Up in the Air")) { - document.add(new Field("movie", movie, Store.YES, Index.NOT_ANALYZED)); - } - writer.addDocument(document); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @Test - public void equals_by_id_matches() throws Exception { - testQuery(person.id.eq("actor_1"), "id:actor_1", 1); - } - - @Test - public void equals_by_id_does_not_match() throws Exception { - testQuery(person.id.eq("actor_8"), "id:actor_8", 0); - } - - @Test - public void equals_by_name_matches() throws Exception { - testQuery(person.name.eq("George Clooney"), "name:George Clooney", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_by_name_ignoring_case_does_not_match() throws Exception { - testQuery(person.name.equalsIgnoreCase("george clooney"), "name:george clooney", 0); - } - - @Test - public void equals_by_name_does_not_match() throws Exception { - testQuery(person.name.eq("George Looney"), "name:George Looney", 0); - } - - @Test - public void starts_with_name_should_match() throws Exception { - testQuery(person.name.startsWith("George C"), "name:George C*", 1); - } - - @Test - public void starts_with_name_should_not_match() throws Exception { - testQuery(person.name.startsWith("George L"), "name:George L*", 0); - } - - @Test - public void ends_with_name_should_match() throws Exception { - testQuery(person.name.endsWith("e Clooney"), "name:*e Clooney", 1); - } - - @Test - public void ends_with_name_should_not_match() throws Exception { - testQuery(person.name.endsWith("e Looney"), "name:*e Looney", 0); - } - - @Test - public void contains_name_should_match() throws Exception { - testQuery(person.name.contains("oney"), "name:*oney*", 1); - } - - @Test - public void contains_name_should_not_match() throws Exception { - testQuery(person.name.contains("bloney"), "name:*bloney*", 0); - } - - @Test - public void in_names_should_match_2() throws Exception { - testQuery( - person.name.in("Brad Pitt", "George Clooney"), "name:Brad Pitt name:George Clooney", 2); - } - - @Test - public void or_by_name_should_match_2() throws Exception { - testQuery( - person.name.eq("Brad Pitt").or(person.name.eq("George Clooney")), - "name:Brad Pitt name:George Clooney", - 2); - } - - @Test - public void equals_by_birth_date() throws Exception { - testQuery(person.birthDate.eq(clooney.getBirthDate()), "birthDate:1961-04-06", 1); - } - - @Test - public void between_phrase() throws Exception { - testQuery( - person.name.between("Brad Pitt", "George Clooney"), - "name:[Brad Pitt TO George Clooney]", - 2); - } - - @Test - public void not_equals_finds_the_actors_and_movies() throws Exception { - testQuery(person.name.ne("Michael Douglas"), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void not_equals_finds_only_clooney_and_movies() throws Exception { - testQuery(person.name.ne("Brad Pitt"), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void and_with_two_not_equals_doesnt_find_the_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").and(person.name.ne("George Clooney")), - "+(-name:Brad Pitt +*:*) +(-name:George Clooney +*:*)", - 1); - } - - @Test - public void or_with_two_not_equals_finds_movies_and_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").or(person.name.ne("George Clooney")), - "(-name:Brad Pitt +*:*) (-name:George Clooney +*:*)", - 3); - } - - @Test - public void negation_of_equals_finds_movies_and_actors() throws Exception { - testQuery(person.name.eq("Michael Douglas").not(), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void negation_of_equals_finds_pitt_and_movies() throws Exception { - testQuery(person.name.eq("Brad Pitt").not(), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void multiple_field_search_from_movies() throws Exception { - StringPath movie = Expressions.stringPath("movie"); - testQuery(movie.in("Interview with the Vampire"), "movie:Interview with the Vampire", 1); - testQuery(movie.eq("Up in the Air"), "movie:Up in the Air", 1); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerTest.java deleted file mode 100644 index c3214f66e5..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/LuceneSerializerTest.java +++ /dev/null @@ -1,718 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import com.querydsl.core.BooleanBuilder; -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.MatchingFiltersFactory; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QuerydslModule; -import com.querydsl.core.StringConstant; -import com.querydsl.core.Target; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.Operation; -import com.querydsl.core.types.Operator; -import com.querydsl.core.types.Ops; -import com.querydsl.core.types.Predicate; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.core.types.dsl.CollectionPath; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.PathBuilder; -import com.querydsl.core.types.dsl.StringPath; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Set; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.DoubleField; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.FloatField; -import org.apache.lucene.document.IntField; -import org.apache.lucene.document.LongField; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.Version; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneSerializer - * - * @author vema - */ -public class LuceneSerializerTest { - private LuceneSerializer serializer; - private PathBuilder entityPath; - private StringPath title; - private StringPath author; - private StringPath text; - private StringPath rating; - private StringPath publisher; - private NumberPath year; - private NumberPath gross; - private CollectionPath titles; - - private NumberPath longField; - private NumberPath shortField; - private NumberPath byteField; - private NumberPath floatField; - - private static final String YEAR_PREFIX_CODED = ""; - private static final String GROSS_PREFIX_CODED = ""; - private static final String LONG_PREFIX_CODED = ""; - private static final String SHORT_PREFIX_CODED = ""; - private static final String BYTE_PREFIX_CODED = ""; - private static final String FLOAT_PREFIX_CODED = ""; - - private IndexWriterConfig config; - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - - private static final Set UNSUPPORTED_OPERATORS = - Collections.unmodifiableSet( - EnumSet.of( - Ops.STARTS_WITH_IC, Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC)); - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private Document createDocument() { - Document doc = new Document(); - - doc.add(new Field("title", new StringReader("Jurassic Park"))); - doc.add(new Field("author", new StringReader("Michael Crichton"))); - doc.add(new Field("text", new StringReader("It's a UNIX system! I know this!"))); - doc.add(new Field("rating", new StringReader("Good"))); - doc.add(new Field("publisher", "", Store.YES, Index.ANALYZED)); - doc.add(new IntField("year", 1990, Store.YES)); - doc.add(new DoubleField("gross", 900.0, Store.YES)); - - doc.add(new LongField("longField", 1, Store.YES)); - doc.add(new IntField("shortField", 1, Store.YES)); - doc.add(new IntField("byteField", 1, Store.YES)); - doc.add(new FloatField("floatField", 1, Store.YES)); - - return doc; - } - - @Before - public void setUp() throws Exception { - serializer = new LuceneSerializer(true, true); - entityPath = new PathBuilder(Object.class, "obj"); - title = entityPath.getString("title"); - author = entityPath.getString("author"); - text = entityPath.getString("text"); - publisher = entityPath.getString("publisher"); - year = entityPath.getNumber("year", Integer.class); - rating = entityPath.getString("rating"); - gross = entityPath.getNumber("gross", Double.class); - titles = entityPath.getCollection("title", String.class, StringPath.class); - - longField = entityPath.getNumber("longField", Long.class); - shortField = entityPath.getNumber("shortField", Short.class); - byteField = entityPath.getNumber("byteField", Byte.class); - floatField = entityPath.getNumber("floatField", Float.class); - - idx = new RAMDirectory(); - config = - new IndexWriterConfig(Version.LUCENE_42, new StandardAnalyzer(Version.LUCENE_42)) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument()); - - writer.close(); - - IndexReader reader = IndexReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @After - public void tearDown() throws Exception { - searcher.getIndexReader().close(); - } - - private void testQuery(Expression expr, int expectedHits) throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - } - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - @Test - public void queryElement() throws Exception { - Query query1 = serializer.toQuery(author.like("Michael"), metadata); - Query query2 = serializer.toQuery(text.like("Text"), metadata); - - BooleanExpression query = Expressions.anyOf(new QueryElement(query1), new QueryElement(query2)); - testQuery(query, "author:michael text:text", 1); - } - - @Test - public void like() throws Exception { - testQuery(author.like("*ichael*"), "author:*ichael*", 1); - } - - @Test - public void like_custom_wildcard_single_character() throws Exception { - testQuery(author.like("Mi?hael"), "author:mi?hael", 1); - } - - @Test - public void like_custom_wildcard_multiple_character() throws Exception { - testQuery(text.like("*U*X*"), "text:*u*x*", 1); - } - - @Test - public void like_phrase() throws Exception { - testQuery(title.like("*rassic Par*"), "+title:**rassic* +title:*par**", 1); - } - - @Test - public void like_or_like() throws Exception { - testQuery(title.like("House").or(author.like("*ichae*")), "title:house author:*ichae*", 1); - } - - @Test - public void like_and_like() throws Exception { - testQuery(title.like("*assic*").and(rating.like("G?od")), "+title:*assic* +rating:g?od", 1); - } - - @Test - public void eq() throws Exception { - testQuery(rating.eq("good"), "rating:good", 1); - } - - @Test - public void eq_with_deep_path() throws Exception { - StringPath deepPath = entityPath.get("property1", Object.class).getString("property2"); - testQuery(deepPath.eq("good"), "property1.property2:good", 0); - } - - @Test - public void fuzzyLike() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good"), "rating:Good~2", 1); - } - - @Test - public void fuzzyLike_with_similarity() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 2), "rating:Good~2", 1); - } - - @Test - public void fuzzyLike_with_similarity_and_prefix() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 2, 0), "rating:Good~2", 1); - } - - @Test - @Ignore - public void eq_numeric_integer() throws Exception { - testQuery(year.eq(1990), "year:" + YEAR_PREFIX_CODED, 1); - } - - @Test - @Ignore - public void eq_numeric_double() throws Exception { - testQuery(gross.eq(900.00), "gross:" + GROSS_PREFIX_CODED, 1); - } - - @Test - @Ignore - public void eq_numeric() throws Exception { - testQuery(longField.eq(1L), "longField:" + LONG_PREFIX_CODED, 1); - testQuery(shortField.eq((short) 1), "shortField:" + SHORT_PREFIX_CODED, 1); - testQuery(byteField.eq((byte) 1), "byteField:" + BYTE_PREFIX_CODED, 1); - testQuery(floatField.eq((float) 1.0), "floatField:" + FLOAT_PREFIX_CODED, 1); - } - - @Test - public void equals_ignores_case() throws Exception { - testQuery(title.eq("Jurassic"), "title:jurassic", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_or_year_equals() throws Exception { - testQuery( - title.equalsIgnoreCase("House").or(year.eq(1990)), - "title:house year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - @Ignore - public void eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)), - "+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - @Ignore - public void eq_and_eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)).and(author.eq("Michael Crichton")), - "+(+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED + ") +author:\"michael crichton\"", - 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_ignore_case_and_or() throws Exception { - testQuery( - title - .equalsIgnoreCase("Jurassic Park") - .and(rating.equalsIgnoreCase("Bad")) - .or(author.equalsIgnoreCase("Michael Crichton")), - "(+title:\"jurassic park\" +rating:bad) author:\"michael crichton\"", - 1); - } - - @Test - public void eq_or_eq_and_eq_does_not_find_results() throws Exception { - testQuery( - title.eq("jeeves").or(rating.eq("superb")).and(author.eq("michael crichton")), - "+(title:jeeves rating:superb) +author:\"michael crichton\"", - 0); - } - - @Test - public void eq_phrase() throws Exception { - testQuery(title.eq("Jurassic Park"), "title:\"jurassic park\"", 1); - } - - @Test - @Ignore("Not easily done in Lucene!") - public void publisher_equals_empty_string() throws Exception { - testQuery(publisher.eq(""), "publisher:", 1); - } - - @Test - public void eq_phrase_should_not_find_results_but_luceNe_semantics_differs_from_querydsls() - throws Exception { - testQuery(text.eq("UNIX System"), "text:\"unix system\"", 1); - } - - @Test - public void eq_phrase_does_not_find_results_because_word_in_middle() throws Exception { - testQuery(title.eq("Jurassic Amusement Park"), "title:\"jurassic amusement park\"", 0); - } - - @Test - public void like_not_does_not_find_results() throws Exception { - testQuery(title.like("*H*e*").not(), "-title:*h*e* +*:*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_negation_or_rating_equals_ignore_case() throws Exception { - testQuery( - title.equalsIgnoreCase("House").not().or(rating.equalsIgnoreCase("Good")), - "-title:house rating:good", - 1); - } - - @Test - public void eq_not_does_not_find_results() throws Exception { - testQuery(title.eq("Jurassic Park").not(), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void title_equals_not_house() throws Exception { - testQuery(title.eq("house").not(), "-title:house +*:*", 1); - } - - @Test - public void eq_and_eq_not_does_not_find_results_because_second_expression_finds_nothing() - throws Exception { - testQuery( - rating.eq("superb").and(title.eq("house").not()), "+rating:superb +(-title:house +*:*)", 0); - } - - @Test - public void not_equals_finds_one() throws Exception { - testQuery(title.ne("house"), "-title:house +*:*", 1); - } - - @Test - public void not_equals_finds_none() throws Exception { - testQuery(title.ne("Jurassic Park"), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void nothing_found_with_not_equals_or_equals() throws Exception { - testQuery( - title.ne("jurassic park").or(rating.eq("lousy")), - "(-title:\"jurassic park\" +*:*) rating:lousy", - 0); - } - - @Test - public void ne_and_eq() throws Exception { - testQuery(title.ne("house").and(rating.eq("good")), "+(-title:house +*:*) +rating:good", 1); - } - - @Test - public void startsWith() throws Exception { - testQuery(title.startsWith("Jurassi"), "title:jurassi*", 1); - } - - @Test - public void startsWith_phrase() throws Exception { - testQuery(title.startsWith("jurassic par"), "+title:jurassic* +title:*par*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void starts_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.startsWithIgnoreCase("urassic Par"), "+title:urassic* +title:*par*", 0); - } - - @Test - public void endsWith() throws Exception { - testQuery(title.endsWith("ark"), "title:*ark", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Park"), "+title:*sic* +title:*park", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Par"), "+title:*sic* +title:*par", 0); - } - - @Test - public void contains() throws Exception { - testQuery(title.contains("rassi"), "title:*rassi*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void contains_ignore_case_phrase() throws Exception { - testQuery(title.containsIgnoreCase("rassi Pa"), "+title:*rassi* +title:*pa*", 1); - } - - @Test - public void contains_user_inputted_wildcards_dont_work() throws Exception { - testQuery(title.contains("r*i"), "title:*r\\*i*", 0); - } - - @Test - public void between() throws Exception { - testQuery(title.between("Indiana", "Kundun"), "title:[indiana TO kundun]", 1); - } - - @Test - public void between_numeric_integer() throws Exception { - testQuery(year.between(1980, 2000), "year:[1980 TO 2000]", 1); - } - - @Test - public void between_numeric_double() throws Exception { - testQuery(gross.between(10.00, 19030.00), "gross:[10.0 TO 19030.0]", 1); - } - - @Test - public void between_numeric() throws Exception { - testQuery(longField.between(0L, 2L), "longField:[0 TO 2]", 1); - testQuery(shortField.between((short) 0, (short) 2), "shortField:[0 TO 2]", 1); - testQuery(byteField.between((byte) 0, (byte) 2), "byteField:[0 TO 2]", 1); - testQuery(floatField.between((float) 0.0, (float) 2.0), "floatField:[0.0 TO 2.0]", 1); - } - - @Test - public void between_is_inclusive_from_start() throws Exception { - testQuery(title.between("Jurassic", "Kundun"), "title:[jurassic TO kundun]", 1); - } - - @Test - public void between_is_inclusive_to_end() throws Exception { - testQuery(title.between("Indiana", "Jurassic"), "title:[indiana TO jurassic]", 1); - } - - @Test - public void between_does_not_find_results() throws Exception { - testQuery(title.between("Indiana", "Jurassib"), "title:[indiana TO jurassib]", 0); - } - - @Test - public void in() throws Exception { - testQuery(title.in(Arrays.asList("jurassic", "park")), "title:jurassic title:park", 1); - testQuery(title.in("jurassic", "park"), "title:jurassic title:park", 1); - testQuery(title.eq("jurassic").or(title.eq("park")), "title:jurassic title:park", 1); - } - - @Test - public void lt() throws Exception { - testQuery(rating.lt("Superb"), "rating:{* TO superb}", 1); - } - - @Test - public void lt_numeric_integer() throws Exception { - testQuery(year.lt(1991), "year:{* TO 1991}", 1); - } - - @Test - public void lt_numeric_double() throws Exception { - testQuery(gross.lt(10000.0), "gross:{* TO 10000.0}", 1); - } - - @Test - public void lt_not_in_range_because_equal() throws Exception { - testQuery(rating.lt("Good"), "rating:{* TO good}", 0); - } - - @Test - public void lt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.lt(1990), "year:{* TO 1990}", 0); - } - - @Test - public void lt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.lt(900.0), "gross:{* TO 900.0}", 0); - } - - @Test - public void loe() throws Exception { - testQuery(rating.loe("Superb"), "rating:[* TO superb]", 1); - } - - @Test - public void loe_numeric_integer() throws Exception { - testQuery(year.loe(1991), "year:[* TO 1991]", 1); - } - - @Test - public void loe_numeric_double() throws Exception { - testQuery(gross.loe(903.0), "gross:[* TO 903.0]", 1); - } - - @Test - public void loe_equal() throws Exception { - testQuery(rating.loe("Good"), "rating:[* TO good]", 1); - } - - @Test - public void loe_numeric_integer_equal() throws Exception { - testQuery(year.loe(1990), "year:[* TO 1990]", 1); - } - - @Test - public void loe_numeric_double_equal() throws Exception { - testQuery(gross.loe(900.0), "gross:[* TO 900.0]", 1); - } - - @Test - public void loe_not_found() throws Exception { - testQuery(rating.loe("Bad"), "rating:[* TO bad]", 0); - } - - @Test - public void loe_numeric_integer_not_found() throws Exception { - testQuery(year.loe(1989), "year:[* TO 1989]", 0); - } - - @Test - public void loe_numeric_double_not_found() throws Exception { - testQuery(gross.loe(899.9), "gross:[* TO 899.9]", 0); - } - - @Test - public void gt() throws Exception { - testQuery(rating.gt("Bad"), "rating:{bad TO *}", 1); - } - - @Test - public void gt_numeric_integer() throws Exception { - testQuery(year.gt(1989), "year:{1989 TO *}", 1); - } - - @Test - public void gt_numeric_double() throws Exception { - testQuery(gross.gt(100.00), "gross:{100.0 TO *}", 1); - } - - @Test - public void gt_not_in_range_because_equal() throws Exception { - testQuery(rating.gt("Good"), "rating:{good TO *}", 0); - } - - @Test - public void gt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.gt(1990), "year:{1990 TO *}", 0); - } - - @Test - public void gt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.gt(900.00), "gross:{900.0 TO *}", 0); - } - - @Test - public void goe() throws Exception { - testQuery(rating.goe("Bad"), "rating:[bad TO *]", 1); - } - - @Test - public void goe_numeric_integer() throws Exception { - testQuery(year.goe(1989), "year:[1989 TO *]", 1); - } - - @Test - public void goe_numeric_double() throws Exception { - testQuery(gross.goe(320.50), "gross:[320.5 TO *]", 1); - } - - @Test - public void goe_equal() throws Exception { - testQuery(rating.goe("Good"), "rating:[good TO *]", 1); - } - - @Test - public void goe_numeric_integer_equal() throws Exception { - testQuery(year.goe(1990), "year:[1990 TO *]", 1); - } - - @Test - public void goe_numeric_double_equal() throws Exception { - testQuery(gross.goe(900.00), "gross:[900.0 TO *]", 1); - } - - @Test - public void goe_not_found() throws Exception { - testQuery(rating.goe("Hood"), "rating:[hood TO *]", 0); - } - - @Test - public void goe_numeric_integer_not_found() throws Exception { - testQuery(year.goe(1991), "year:[1991 TO *]", 0); - } - - @Test - public void goe_numeric_double_not_found() throws Exception { - testQuery(gross.goe(900.10), "gross:[900.1 TO *]", 0); - } - - @Test - public void equals_empty_string() throws Exception { - testQuery(title.eq(""), "title:", 0); - } - - @Test - public void not_equals_empty_string() throws Exception { - testQuery(title.ne(""), "-title: +*:*", 1); - } - - @Test - public void contains_empty_string() throws Exception { - testQuery(title.contains(""), "title:**", 1); - } - - @Test - public void like_empty_string() throws Exception { - testQuery(title.like(""), "title:", 0); - } - - @Test - public void starts_with_empty_string() throws Exception { - testQuery(title.startsWith(""), "title:*", 1); - } - - @Test - public void ends_with_empty_string() throws Exception { - testQuery(title.endsWith(""), "title:*", 1); - } - - @Test - public void between_empty_strings() throws Exception { - testQuery(title.between("", ""), "title:[ TO ]", 0); - } - - @Test - public void booleanBuilder() throws Exception { - testQuery(new BooleanBuilder(gross.goe(900.10)), "gross:[900.1 TO *]", 0); - } - - @Test - @Ignore - public void fuzzy() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void proximity() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void boost() throws Exception { - fail("Not yet implemented!"); - } - - @Test - public void pathAny() throws Exception { - testQuery(titles.any().eq("Jurassic"), "title:jurassic", 1); - } - - private boolean unsupportedOperation(Predicate filter) { - return UNSUPPORTED_OPERATORS.contains(((Operation) filter).getOperator()); - } - - @Test - public void various() throws Exception { - MatchingFiltersFactory filters = - new MatchingFiltersFactory(QuerydslModule.LUCENE, Target.LUCENE); - for (Predicate filter : filters.string(title, StringConstant.create("jurassic park"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(author, StringConstant.create("michael crichton"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(title, StringConstant.create("1990"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 0); - } - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/Person.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/Person.java deleted file mode 100644 index d201e3c2b5..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/Person.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.annotations.QueryEntity; -import java.time.LocalDate; - -@QueryEntity -public class Person { - private final String id; - private final String name; - private final LocalDate birthDate; - - public Person(String id, String name, LocalDate birthDate) { - this.id = id; - this.name = name; - this.birthDate = birthDate; - } - - public String getId() { - return id; - } - - public LocalDate getBirthDate() { - return birthDate; - } - - public String getName() { - return name; - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/PhraseElementTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/PhraseElementTest.java deleted file mode 100644 index 7c94e762cc..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/PhraseElementTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class PhraseElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, false); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:Hello World"); - assertThat(serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - } - - @Test - public void equals() { - PhraseElement el1 = new PhraseElement("x"), - el2 = new PhraseElement("x"), - el3 = new PhraseElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - } - - @Test - public void hashCode_() { - PhraseElement el1 = new PhraseElement("x"), el2 = new PhraseElement("x"); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QDocument.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QDocument.java deleted file mode 100644 index e55c66f386..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QDocument.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import com.querydsl.core.types.PathMetadataFactory; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import org.apache.lucene.document.Document; - -public class QDocument extends EntityPathBase { - - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(final String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final NumberPath year = createNumber("year", Integer.class); - - public final StringPath title = createString("title"); - - public final NumberPath gross = createNumber("gross", Double.class); -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QueryElementTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QueryElementTest.java deleted file mode 100644 index 0049bd96be..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/QueryElementTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.lucene.index.Term; -import org.apache.lucene.search.TermQuery; -import org.junit.Ignore; -import org.junit.Test; - -public class QueryElementTest { - - @Test - @Ignore - public void test() { - QueryElement element = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element.toString()).isEqualTo("str:text"); - // assertEquals(element.getQuery().hashCode(), element.hashCode()); - - QueryElement element2 = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element).isEqualTo(element2); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/TermElementTest.java b/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/TermElementTest.java deleted file mode 100644 index f552069711..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/java/com/querydsl/lucene4/TermElementTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene4; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class TermElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, true); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - assertThat(serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString()) - .isEqualTo("title:Hello World"); - } - - @Test - public void testEqualsAndHashCode() { - TermElement el1 = new TermElement("x"), el2 = new TermElement("x"), el3 = new TermElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene4/src/test/resources/log4j.properties.example b/querydsl-libraries/querydsl-lucene4/src/test/resources/log4j.properties.example deleted file mode 100644 index 50eef686c1..0000000000 --- a/querydsl-libraries/querydsl-lucene4/src/test/resources/log4j.properties.example +++ /dev/null @@ -1,9 +0,0 @@ -# Configure an appender that logs to console -log4j.rootLogger=info, A1 -log4j.threshold=debug -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c{1} - %m%n - -# Configuration of logging levels for different packages -log4j.logger.com.querydsl.lucene4=DEBUG diff --git a/querydsl-libraries/querydsl-lucene5/README.md b/querydsl-libraries/querydsl-lucene5/README.md deleted file mode 100644 index 3bcd908515..0000000000 --- a/querydsl-libraries/querydsl-lucene5/README.md +++ /dev/null @@ -1,57 +0,0 @@ -## Querydsl Lucene 5 - -The Lucene module provides integration with the Lucene 5 indexing library. - -**Maven integration** - - Add the following dependencies to your Maven project : -```XML - - io.github.openfeign.querydsl - querydsl-lucene5 - ${querydsl.version} - -``` - -**Creating the query types** - -With fields year and title a manually created query type could look something like this: - -```JAVA -public class QDocument extends EntityPathBase{ - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final StringPath year = createString("year"); - - public final StringPath title = createString("title"); -} -``` - -QDocument represents a Lucene document with the fields year and title. - -Code generation is not available for Lucene, since no schema data is available. - -**Querying** - -Querying with Querydsl Lucene is as simple as this: - -```JAVA -QDocument doc = new QDocument("doc"); - -IndexSearcher searcher = new IndexSearcher(index); -LuceneQuery query = new LuceneQuery(true, searcher); -List documents = query - .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle")) - .fetch(); -``` - -which is transformed into the following Lucene query : -``` -+year:[1800 TO 2000] +title:huckle* -``` - -For more information on the Querydsl Lucene module visit the reference documentation http://www.querydsl.com/static/querydsl/latest/reference/html/ch02s05.html diff --git a/querydsl-libraries/querydsl-lucene5/pom.xml b/querydsl-libraries/querydsl-lucene5/pom.xml deleted file mode 100644 index 53134d5322..0000000000 --- a/querydsl-libraries/querydsl-lucene5/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - - - io.github.openfeign.querydsl - querydsl-libraries - 6.0-SNAPSHOT - - - querydsl-lucene5 - Querydsl - Lucene 5 support - Lucene support for Querydsl - - - 5.5.5 - org.apache.lucene.*;version="[5.1.0,6)", - ${osgi.import.package.root} - - - - - org.jetbrains - annotations - provided - - - org.apache.lucene - lucene-core - ${lucene.version} - provided - - - org.apache.lucene - lucene-analyzers-common - ${lucene.version} - provided - - - org.apache.lucene - lucene-queryparser - ${lucene.version} - provided - - - org.apache.lucene - lucene-queries - ${lucene.version} - provided - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - - - - - io.github.openfeign.querydsl - querydsl-core - ${project.version} - test-jar - test - - - - io.github.openfeign.querydsl - querydsl-apt - ${project.version} - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - com.querydsl.lucene5 - - - - - - - org.apache.felix - maven-bundle-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - - com.querydsl.apt.QuerydslAnnotationProcessor - - - - - - diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java deleted file mode 100644 index 1a9159f651..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/AbstractLuceneQuery.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.EmptyCloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.Fetchable; -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.SimpleQuery; -import com.querydsl.core.support.QueryMixin; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.ParamExpression; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.Predicate; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.sandbox.queries.DuplicateFilter; -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.QueryWrapperFilter; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.TotalHitCountCollector; -import org.jetbrains.annotations.Nullable; - -/** - * AbstractLuceneQuery is an abstract super class for Lucene query implementations - * - * @author tiwe - * @param projection type - * @param concrete subtype of querydsl - */ -public abstract class AbstractLuceneQuery> - implements SimpleQuery, Fetchable { - - private static final String JAVA_ISO_CONTROL = "[\\p{Cntrl}&&[^\r\n\t]]"; - - private final QueryMixin queryMixin; - - private final IndexSearcher searcher; - - private final LuceneSerializer serializer; - - private final Function transformer; - - @Nullable private Set fieldsToLoad; - - private List filters = Collections.emptyList(); - - @Nullable private Filter filter; - - @Nullable private Sort querySort; - - @SuppressWarnings("unchecked") - public AbstractLuceneQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - queryMixin = new QueryMixin((Q) this, new DefaultQueryMetadata()); - this.serializer = serializer; - this.searcher = searcher; - this.transformer = transformer; - } - - public AbstractLuceneQuery(IndexSearcher searcher, Function transformer) { - this(LuceneSerializer.DEFAULT, searcher, transformer); - } - - private long innerCount() { - try { - final int maxDoc = searcher.getIndexReader().maxDoc(); - if (maxDoc == 0) { - return 0; - } - TotalHitCountCollector collector = new TotalHitCountCollector(); - searcher.search(createQuery(), getFilter(), collector); - return collector.getTotalHits(); - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public long fetchCount() { - return innerCount(); - } - - protected Query createQuery() { - Query returnedQuery = null; - Query originalQuery = null; - if (queryMixin.getMetadata().getWhere() == null) { - originalQuery = new MatchAllDocsQuery(); - } else { - originalQuery = - serializer.toQuery(queryMixin.getMetadata().getWhere(), queryMixin.getMetadata()); - } - Filter filter = getFilter(); - if (filter != null) { - BooleanQuery booleanQuery = new BooleanQuery(); - booleanQuery.add(originalQuery, Occur.MUST); - booleanQuery.add(filter, Occur.FILTER); - returnedQuery = booleanQuery; - } else { - returnedQuery = originalQuery; - } - - return returnedQuery; - } - - /** - * Create a filter for constraints defined in this querydsl - * - * @return filter - */ - public Filter asFilter() { - return new QueryWrapperFilter(createQuery()); - } - - @Override - public Q distinct() { - throw new UnsupportedOperationException("use distinct(path) instead"); - } - - /** - * Add a DuplicateFilter for the field of the given property path - * - * @param property distinct property - * @return the current object - */ - public Q distinct(Path property) { - return filter(new DuplicateFilter(serializer.toField(property))); - } - - /** - * Apply the given Lucene filter to the search results - * - * @param filter filter - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q filter(Filter filter) { - if (filters.isEmpty()) { - this.filter = filter; - filters = Collections.singletonList(filter); - } else { - this.filter = null; - if (filters.size() == 1) { - filters = new ArrayList(); - } - filters.add(filter); - } - return (Q) this; - } - - private Filter getFilter() { - if (filter == null && !filters.isEmpty()) { - BooleanQuery filterQuery = new BooleanQuery(); - for (Filter filter : filters) { - filterQuery.add(filter, Occur.SHOULD); - } - filter = new QueryWrapperFilter(filterQuery); - } - return filter; - } - - @Override - public Q limit(long limit) { - return queryMixin.limit(limit); - } - - @Override - public CloseableIterator iterate() { - final QueryMetadata metadata = queryMixin.getMetadata(); - final List> orderBys = metadata.getOrderBy(); - final Integer queryLimit = metadata.getModifiers().getLimitAsInteger(); - final Integer queryOffset = metadata.getModifiers().getOffsetAsInteger(); - Sort sort = querySort; - int limit; - final int offset = queryOffset != null ? queryOffset : 0; - try { - limit = maxDoc(); - if (limit == 0) { - return new EmptyCloseableIterator(); - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - if (queryLimit != null && queryLimit < limit) { - limit = queryLimit; - } - if (sort == null && !orderBys.isEmpty()) { - sort = serializer.toSort(orderBys); - } - - try { - ScoreDoc[] scoreDocs; - int sumOfLimitAndOffset = limit + offset; - if (sumOfLimitAndOffset < 1) { - throw new QueryException( - "The given limit (" - + limit - + ") and offset (" - + offset - + ") cause an integer overflow."); - } - if (sort != null) { - scoreDocs = - searcher.search( - createQuery(), - // sumOfLimitAndOffset).scoreDocs; - sumOfLimitAndOffset, - sort, - false, - false) - .scoreDocs; - } else { - scoreDocs = - searcher.search(createQuery(), sumOfLimitAndOffset, Sort.INDEXORDER, false, false) - .scoreDocs; - } - if (offset < scoreDocs.length) { - return new ResultIterator(scoreDocs, offset, searcher, fieldsToLoad, transformer); - } - return new EmptyCloseableIterator(); - } catch (final IOException e) { - throw new QueryException(e); - } - } - - private List innerList() { - return new IteratorAdapter(iterate()).asList(); - } - - @Override - public List fetch() { - return innerList(); - } - - /** - * Set the given fields to load - * - * @param fieldsToLoad fields to load - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(Set fieldsToLoad) { - this.fieldsToLoad = fieldsToLoad; - return (Q) this; - } - - /** - * Load only the fields of the given paths - * - * @param paths fields to load - * @return the current object - */ - @SuppressWarnings("unchecked") - public Q load(Path... paths) { - Set fields = new HashSet(); - for (Path path : paths) { - fields.add(serializer.toField(path)); - } - this.fieldsToLoad = fields; - return (Q) this; - } - - @Override - public QueryResults fetchResults() { - List documents = innerList(); - /* - * TODO Get rid of fetchCount(). It could be implemented by iterating - * the fetch results in fetch* from n to m. - */ - return new QueryResults(documents, queryMixin.getMetadata().getModifiers(), innerCount()); - } - - @Override - public Q offset(long offset) { - return queryMixin.offset(offset); - } - - public Q orderBy(OrderSpecifier o) { - return queryMixin.orderBy(o); - } - - @Override - public Q orderBy(OrderSpecifier... o) { - return queryMixin.orderBy(o); - } - - @Override - public Q restrict(QueryModifiers modifiers) { - return queryMixin.restrict(modifiers); - } - - @Override - public

Q set(ParamExpression

param, P value) { - return queryMixin.set(param, value); - } - - @SuppressWarnings("unchecked") - public Q sort(Sort sort) { - this.querySort = sort; - return (Q) this; - } - - @Nullable - private T oneResult(boolean unique) { - try { - int maxDoc = maxDoc(); - if (maxDoc == 0) { - return null; - } - final ScoreDoc[] scoreDocs = - searcher.search(createQuery(), maxDoc, Sort.INDEXORDER, false, false).scoreDocs; - int index = 0; - QueryModifiers modifiers = queryMixin.getMetadata().getModifiers(); - Long offset = modifiers.getOffset(); - if (offset != null) { - index = offset.intValue(); - } - Long limit = modifiers.getLimit(); - if (unique - && (limit == null ? scoreDocs.length - index > 1 : limit > 1 && scoreDocs.length > 1)) { - throw new NonUniqueResultException( - "Unique result requested, but " + scoreDocs.length + " found."); - } else if (scoreDocs.length > index) { - Document document; - if (fieldsToLoad != null) { - document = searcher.doc(scoreDocs[index].doc, fieldsToLoad); - } else { - document = searcher.doc(scoreDocs[index].doc); - } - return transformer.apply(document); - } else { - return null; - } - } catch (IOException | IllegalArgumentException e) { - throw new QueryException(e); - } - } - - @Override - public T fetchFirst() { - return oneResult(false); - } - - @Override - public T fetchOne() throws NonUniqueResultException { - return oneResult(true); - } - - public Q where(Predicate e) { - return queryMixin.where(e); - } - - @Override - public Q where(Predicate... e) { - return queryMixin.where(e); - } - - @Override - public String toString() { - return createQuery().toString().replaceAll(JAVA_ISO_CONTROL, "_"); - } - - private int maxDoc() throws IOException { - return searcher.getIndexReader().maxDoc(); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/IgnoreCaseUnsupportedException.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/IgnoreCaseUnsupportedException.java deleted file mode 100644 index de7c597b38..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/IgnoreCaseUnsupportedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -/** - * Thrown for case ignore usage - * - * @author tiwe - */ -public class IgnoreCaseUnsupportedException extends UnsupportedOperationException { - - private static final long serialVersionUID = 412913389929530788L; - - public IgnoreCaseUnsupportedException() { - super("Ignore case queries are not supported with Lucene"); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneExpressions.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneExpressions.java deleted file mode 100644 index a1bc496729..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneExpressions.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.BooleanExpression; -import org.apache.lucene.index.Term; -import org.apache.lucene.search.FuzzyQuery; -import org.apache.lucene.util.automaton.LevenshteinAutomata; - -/** - * Utility methods to create filter expressions for Lucene queries that are not covered by the - * Querydsl standard expression model - * - * @author tiwe - */ -public final class LuceneExpressions { - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @return condition - */ - public static BooleanExpression fuzzyLike(Path path, String value) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param maxEdits must be >= 0 and <= {@link - * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}. - * @return condition - */ - public static BooleanExpression fuzzyLike(Path path, String value, int maxEdits) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, maxEdits)); - } - - /** - * Create a fuzzy query - * - * @param path path - * @param value value to match - * @param maxEdits must be >= 0 and <= {@link - * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}. - * @param prefixLength length of common (non-fuzzy) prefix - * @return condition - */ - public static BooleanExpression fuzzyLike( - Path path, String value, int maxEdits, int prefixLength) { - Term term = new Term(path.getMetadata().getName(), value); - return new QueryElement(new FuzzyQuery(term, maxEdits, prefixLength)); - } - - private LuceneExpressions() {} -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneOps.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneOps.java deleted file mode 100644 index 375316fe25..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneOps.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.Operator; - -/** - * Lucene specific operators - * - * @author tiwe - */ -public enum LuceneOps implements Operator { - LUCENE_QUERY(Object.class), - PHRASE(String.class), - TERM(String.class); - - private final Class type; - - LuceneOps(Class type) { - this.type = type; - } - - @Override - public Class getType() { - return type; - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneQuery.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneQuery.java deleted file mode 100644 index 9c7fa0431c..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneQuery.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code LuceneQuery} is a Querydsl query implementation for Lucene queries. - * - *

Example: - * - *

{@code
- * QDocument doc = new QDocument("doc");
- * IndexSearcher searcher = new IndexSearcher(index);
- * LuceneQuery query = new LuceneQuery(true, searcher);
- * List documents = query
- *     .where(doc.year.between("1800", "2000").and(doc.title.startsWith("Huckle"))
- *     .fetch();
- * }
- * - * @author vema - */ -public class LuceneQuery extends AbstractLuceneQuery { - - private static final Function TRANSFORMER = - new Function() { - @Override - public Document apply(Document input) { - return input; - } - }; - - public LuceneQuery(IndexSearcher searcher) { - super(searcher, TRANSFORMER); - } - - public LuceneQuery(LuceneSerializer luceneSerializer, IndexSearcher searcher) { - super(luceneSerializer, searcher, TRANSFORMER); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java deleted file mode 100644 index 2601e07f8a..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.Constant; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.ExpressionUtils; -import com.querydsl.core.types.Operation; -import com.querydsl.core.types.Operator; -import com.querydsl.core.types.Ops; -import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.ParamExpression; -import com.querydsl.core.types.ParamNotSetException; -import com.querydsl.core.types.Path; -import com.querydsl.core.types.PathMetadata; -import com.querydsl.core.types.PathType; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.apache.lucene.index.Term; -import org.apache.lucene.queryparser.classic.QueryParser; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanClause.Occur; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.NumericRangeQuery; -import org.apache.lucene.search.PhraseQuery; -import org.apache.lucene.search.PrefixQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.Sort; -import org.apache.lucene.search.SortField; -import org.apache.lucene.search.SortedNumericSortField; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TermRangeQuery; -import org.apache.lucene.search.WildcardQuery; -import org.apache.lucene.util.BytesRef; -import org.apache.lucene.util.BytesRefBuilder; -import org.apache.lucene.util.NumericUtils; -import org.jetbrains.annotations.Nullable; - -/** - * Serializes Querydsl queries to Lucene queries. - * - * @author vema - */ -public class LuceneSerializer { - private static final Map, SortField.Type> sortFields = - new HashMap, SortField.Type>(); - - static { - sortFields.put(Integer.class, SortField.Type.INT); - sortFields.put(Float.class, SortField.Type.FLOAT); - sortFields.put(Long.class, SortField.Type.LONG); - sortFields.put(Double.class, SortField.Type.DOUBLE); - sortFields.put(BigDecimal.class, SortField.Type.DOUBLE); - sortFields.put(BigInteger.class, SortField.Type.LONG); - } - - public static final LuceneSerializer DEFAULT = new LuceneSerializer(false, true); - - private final boolean lowerCase; - - private final boolean splitTerms; - - private final Locale sortLocale; - - public LuceneSerializer(boolean lowerCase, boolean splitTerms) { - this(lowerCase, splitTerms, Locale.getDefault()); - } - - public LuceneSerializer(boolean lowerCase, boolean splitTerms, Locale sortLocale) { - this.lowerCase = lowerCase; - this.splitTerms = splitTerms; - this.sortLocale = sortLocale; - } - - private Query toQuery(Operation operation, QueryMetadata metadata) { - Operator op = operation.getOperator(); - if (op == Ops.OR) { - return toTwoHandSidedQuery(operation, Occur.SHOULD, metadata); - } else if (op == Ops.AND) { - return toTwoHandSidedQuery(operation, Occur.MUST, metadata); - } else if (op == Ops.NOT) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(toQuery(operation.getArg(0), metadata), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } else if (op == Ops.LIKE) { - return like(operation, metadata); - } else if (op == Ops.LIKE_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.EQ) { - return eq(operation, metadata, false); - } else if (op == Ops.EQ_IGNORE_CASE) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.NE) { - return ne(operation, metadata, false); - } else if (op == Ops.STARTS_WITH) { - return startsWith(metadata, operation, false); - } else if (op == Ops.STARTS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.ENDS_WITH) { - return endsWith(operation, metadata, false); - } else if (op == Ops.ENDS_WITH_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.STRING_CONTAINS) { - return stringContains(operation, metadata, false); - } else if (op == Ops.STRING_CONTAINS_IC) { - throw new IgnoreCaseUnsupportedException(); - } else if (op == Ops.BETWEEN) { - return between(operation, metadata); - } else if (op == Ops.IN) { - return in(operation, metadata, false); - } else if (op == Ops.NOT_IN) { - return notIn(operation, metadata, false); - } else if (op == Ops.LT) { - return lt(operation, metadata); - } else if (op == Ops.GT) { - return gt(operation, metadata); - } else if (op == Ops.LOE) { - return le(operation, metadata); - } else if (op == Ops.GOE) { - return ge(operation, metadata); - } else if (op == LuceneOps.LUCENE_QUERY) { - @SuppressWarnings("unchecked") - // this is the expected type - Constant expectedConstant = (Constant) operation.getArg(0); - return expectedConstant.getConstant(); - } - throw new UnsupportedOperationException("Illegal operation " + operation); - } - - private Query toTwoHandSidedQuery(Operation operation, Occur occur, QueryMetadata metadata) { - Query lhs = toQuery(operation.getArg(0), metadata); - Query rhs = toQuery(operation.getArg(1), metadata); - BooleanQuery bq = new BooleanQuery(); - bq.add(createBooleanClause(lhs, occur)); - bq.add(createBooleanClause(rhs, occur)); - return bq; - } - - /** - * If the query is a BooleanQuery and it contains a single Occur.MUST_NOT clause it will be - * returned as is. Otherwise it will be wrapped in a BooleanClause with the given Occur. - */ - private BooleanClause createBooleanClause(Query query, Occur occur) { - if (query instanceof BooleanQuery) { - BooleanClause[] clauses = ((BooleanQuery) query).getClauses(); - if (clauses.length == 1 && clauses[0].getOccur().equals(Occur.MUST_NOT)) { - return clauses[0]; - } - } - return new BooleanClause(query, occur); - } - - protected Query like(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convert(path, operation.getArg(1)); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, terms[0])); - } - - protected Query eq(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - - if (Number.class.isAssignableFrom(operation.getArg(1).getType())) { - @SuppressWarnings("unchecked") - // guarded by previous check - Constant rightArg = (Constant) operation.getArg(1); - return new TermQuery(new Term(field, convertNumber(rightArg.getConstant()))); - } - - return eq(field, convert(path, operation.getArg(1), metadata), ignoreCase); - } - - private BytesRef convertNumber(Number number) { - if (Integer.class.isInstance(number) - || Byte.class.isInstance(number) - || Short.class.isInstance(number)) { - BytesRefBuilder ref = new BytesRefBuilder(); - NumericUtils.intToPrefixCoded(number.intValue(), 0, ref); - return ref.get(); - } else if (Double.class.isInstance(number) || BigDecimal.class.isInstance(number)) { - BytesRefBuilder ref = new BytesRefBuilder(); - long l = NumericUtils.doubleToSortableLong(number.doubleValue()); - NumericUtils.longToPrefixCoded(l, 0, ref); - return ref.get(); - } else if (Long.class.isInstance(number) || BigInteger.class.isInstance(number)) { - BytesRefBuilder ref = new BytesRefBuilder(); - NumericUtils.longToPrefixCoded(number.longValue(), 0, ref); - return ref.get(); - } else if (Float.class.isInstance(number)) { - BytesRefBuilder ref = new BytesRefBuilder(); - int i = NumericUtils.floatToSortableInt(number.floatValue()); - NumericUtils.intToPrefixCoded(i, 0, ref); - return ref.get(); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + number.getClass().getName()); - } - } - - protected Query eq(String field, String[] terms, boolean ignoreCase) { - if (terms.length > 1) { - PhraseQuery pq = new PhraseQuery(); - for (String s : terms) { - pq.add(new Term(field, s)); - } - return pq; - } - return new TermQuery(new Term(field, terms[0])); - } - - protected Query in(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - Path path = getPath(operation.getArg(0)); - String field = toField(path); - @SuppressWarnings("unchecked") - // this is the expected type - Constant> expectedConstant = (Constant>) operation.getArg(1); - Collection values = expectedConstant.getConstant(); - BooleanQuery bq = new BooleanQuery(); - if (Number.class.isAssignableFrom(path.getType())) { - for (Object value : values) { - TermQuery eq = new TermQuery(new Term(field, convertNumber((Number) value))); - bq.add(eq, Occur.SHOULD); - } - } else { - for (Object value : values) { - String[] str = convert(path, value); - bq.add(eq(field, str, ignoreCase), Occur.SHOULD); - } - } - return bq; - } - - protected Query notIn(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(in(operation, metadata, false), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query ne(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - BooleanQuery bq = new BooleanQuery(); - bq.add(new BooleanClause(eq(operation, metadata, ignoreCase), Occur.MUST_NOT)); - bq.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST)); - return bq; - } - - protected Query startsWith(QueryMetadata metadata, Operation operation, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == 0 ? terms[i] + "*" : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new PrefixQuery(new Term(field, terms[0])); - } - - protected Query stringContains( - Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (String s : terms) { - bq.add(new WildcardQuery(new Term(field, "*" + s + "*")), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0] + "*")); - } - - protected Query endsWith(Operation operation, QueryMetadata metadata, boolean ignoreCase) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - String field = toField(path); - String[] terms = convertEscaped(path, operation.getArg(1), metadata); - if (terms.length > 1) { - BooleanQuery bq = new BooleanQuery(); - for (int i = 0; i < terms.length; ++i) { - String s = i == terms.length - 1 ? "*" + terms[i] : "*" + terms[i] + "*"; - bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST); - } - return bq; - } - return new WildcardQuery(new Term(field, "*" + terms[0])); - } - - protected Query between(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - // TODO Phrase not properly supported - return range( - path, toField(path), operation.getArg(1), operation.getArg(2), true, true, metadata); - } - - protected Query lt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), false, false, metadata); - } - - protected Query gt(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, false, false, metadata); - } - - protected Query le(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), null, operation.getArg(1), true, true, metadata); - } - - protected Query ge(Operation operation, QueryMetadata metadata) { - verifyArguments(operation); - Path path = getPath(operation.getArg(0)); - return range(path, toField(path), operation.getArg(1), null, true, true, metadata); - } - - protected Query range( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - if (min != null && Number.class.isAssignableFrom(min.getType()) - || max != null && Number.class.isAssignableFrom(max.getType())) { - @SuppressWarnings("unchecked") - // guarded by previous check - Constant minConstant = (Constant) min; - @SuppressWarnings("unchecked") - // guarded by previous check - Constant maxConstant = (Constant) max; - - Class numType = - minConstant != null ? minConstant.getType() : maxConstant.getType(); - // this is not necessarily safe, but compile time checking - // on the user side mandates these types to be interchangeable - @SuppressWarnings("unchecked") - Class unboundedNumType = (Class) numType; - return numericRange( - unboundedNumType, - field, - minConstant == null ? null : minConstant.getConstant(), - maxConstant == null ? null : maxConstant.getConstant(), - minInc, - maxInc); - } - return stringRange(leftHandSide, field, min, max, minInc, maxInc, metadata); - } - - protected NumericRangeQuery numericRange( - Class clazz, - String field, - @Nullable N min, - @Nullable N max, - boolean minInc, - boolean maxInc) { - if (clazz.equals(Integer.class)) { - return NumericRangeQuery.newIntRange(field, (Integer) min, (Integer) max, minInc, maxInc); - } else if (clazz.equals(Double.class)) { - return NumericRangeQuery.newDoubleRange(field, (Double) min, (Double) max, minInc, minInc); - } else if (clazz.equals(Float.class)) { - return NumericRangeQuery.newFloatRange(field, (Float) min, (Float) max, minInc, minInc); - } else if (clazz.equals(Long.class)) { - return NumericRangeQuery.newLongRange(field, (Long) min, (Long) max, minInc, minInc); - } else if (clazz.equals(Byte.class) || clazz.equals(Short.class)) { - return NumericRangeQuery.newIntRange( - field, - min != null ? min.intValue() : null, - max != null ? max.intValue() : null, - minInc, - maxInc); - } else { - throw new IllegalArgumentException("Unsupported numeric type " + clazz.getName()); - } - } - - protected Query stringRange( - Path leftHandSide, - String field, - @Nullable Expression min, - @Nullable Expression max, - boolean minInc, - boolean maxInc, - QueryMetadata metadata) { - - if (min == null) { - return TermRangeQuery.newStringRange( - field, null, convert(leftHandSide, max, metadata)[0], minInc, maxInc); - } else if (max == null) { - return TermRangeQuery.newStringRange( - field, convert(leftHandSide, min, metadata)[0], null, minInc, maxInc); - } else { - return TermRangeQuery.newStringRange( - field, - convert(leftHandSide, min, metadata)[0], - convert(leftHandSide, max, metadata)[0], - minInc, - maxInc); - } - } - - private Path getPath(Expression leftHandSide) { - if (leftHandSide instanceof Path) { - return (Path) leftHandSide; - } else if (leftHandSide instanceof Operation) { - Operation operation = (Operation) leftHandSide; - if (operation.getOperator() == Ops.LOWER || operation.getOperator() == Ops.UPPER) { - return (Path) operation.getArg(0); - } - } - throw new IllegalArgumentException("Unable to transform " + leftHandSide + " to path"); - } - - /** - * template method, override to customize - * - * @param path path - * @return field name - */ - protected String toField(Path path) { - PathMetadata md = path.getMetadata(); - if (md.getPathType() == PathType.COLLECTION_ANY) { - return toField(md.getParent()); - } else { - String rv = md.getName(); - if (md.getParent() != null) { - Path parent = md.getParent(); - if (parent.getMetadata().getPathType() != PathType.VARIABLE) { - rv = toField(parent) + "." + rv; - } - } - return rv; - } - } - - private void verifyArguments(Operation operation) { - List> arguments = operation.getArgs(); - for (int i = 1; i < arguments.size(); ++i) { - if (!(arguments.get(i) instanceof Constant) - && !(arguments.get(i) instanceof ParamExpression) - && !(arguments.get(i) instanceof PhraseElement) - && !(arguments.get(i) instanceof TermElement)) { - throw new IllegalArgumentException( - "operand was of unsupported type " + arguments.get(i).getClass().getName()); - } - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - if (rightHandSide instanceof Operation) { - Operation operation = (Operation) rightHandSide; - if (operation.getOperator() == LuceneOps.PHRASE) { - return operation.getArg(0).toString().split("\\s+"); - } else if (operation.getOperator() == LuceneOps.TERM) { - return new String[] {operation.getArg(0).toString()}; - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } else if (rightHandSide instanceof ParamExpression) { - Object value = metadata.getParams().get(rightHandSide); - if (value == null) { - throw new ParamNotSetException((ParamExpression) rightHandSide); - } - return convert(leftHandSide, value); - - } else if (rightHandSide instanceof Constant) { - return convert(leftHandSide, ((Constant) rightHandSide).getConstant()); - } else { - throw new IllegalArgumentException(rightHandSide.toString()); - } - } - - /** - * template method - * - * @param leftHandSide left hand side - * @param rightHandSide right hand side - * @return results - */ - protected String[] convert(Path leftHandSide, Object rightHandSide) { - String str = rightHandSide.toString(); - if (lowerCase) { - str = str.toLowerCase(); - } - if (splitTerms) { - if (str.equals("")) { - return new String[] {str}; - } else { - return str.split("\\s+"); - } - } else { - return new String[] {str}; - } - } - - private String[] convertEscaped( - Path leftHandSide, Expression rightHandSide, QueryMetadata metadata) { - String[] str = convert(leftHandSide, rightHandSide, metadata); - for (int i = 0; i < str.length; i++) { - str[i] = QueryParser.escape(str[i]); - } - return str; - } - - public Query toQuery(Expression expr, QueryMetadata metadata) { - if (expr instanceof Operation) { - return toQuery((Operation) expr, metadata); - } else { - return toQuery(ExpressionUtils.extract(expr), metadata); - } - } - - public Sort toSort(List> orderBys) { - List sorts = new ArrayList(orderBys.size()); - for (OrderSpecifier order : orderBys) { - if (!(order.getTarget() instanceof Path)) { - throw new IllegalArgumentException("argument was not of type Path."); - } - Class type = order.getTarget().getType(); - boolean reverse = !order.isAscending(); - Path path = getPath(order.getTarget()); - if (Number.class.isAssignableFrom(type)) { - sorts.add(new SortedNumericSortField(toField(path), sortFields.get(type), reverse)); - } else { - sorts.add(new SortField(toField(path), SortField.Type.STRING, reverse)); - } - } - Sort sort = new Sort(); - sort.setSort(sorts.toArray(new SortField[0])); - return sort; - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/PhraseElement.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/PhraseElement.java deleted file mode 100644 index b41cc8b839..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/PhraseElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code PhraseElement} represents the embedded String as a phrase - * - * @author tiwe - */ -public class PhraseElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public PhraseElement(String str) { - super(LuceneOps.PHRASE, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/QueryElement.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/QueryElement.java deleted file mode 100644 index 33d2c781b6..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/QueryElement.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.BooleanOperation; -import org.apache.lucene.search.Query; - -/** - * {@code QueryElement} wraps a Lucene Query - * - * @author tiwe - */ -public class QueryElement extends BooleanOperation { - - private static final long serialVersionUID = 470868107363840155L; - - public QueryElement(Query query) { - super(LuceneOps.LUCENE_QUERY, ConstantImpl.create(query)); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/ResultIterator.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/ResultIterator.java deleted file mode 100644 index 42fe409577..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/ResultIterator.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.mysema.commons.lang.CloseableIterator; -import com.querydsl.core.QueryException; -import java.io.IOException; -import java.util.Set; -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.ScoreDoc; -import org.jetbrains.annotations.Nullable; - -/** - * {@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results - * - * @author tiwe - * @param - */ -public final class ResultIterator implements CloseableIterator { - - private final ScoreDoc[] scoreDocs; - - private int cursor; - - private final IndexSearcher searcher; - - @Nullable private final Set fieldsToLoad; - - private final Function transformer; - - public ResultIterator( - ScoreDoc[] scoreDocs, - int offset, - IndexSearcher searcher, - @Nullable Set fieldsToLoad, - Function transformer) { - this.scoreDocs = scoreDocs.clone(); - this.cursor = offset; - this.searcher = searcher; - this.fieldsToLoad = fieldsToLoad; - this.transformer = transformer; - } - - @Override - public boolean hasNext() { - return cursor != scoreDocs.length; - } - - @Override - public T next() { - try { - Document document; - if (fieldsToLoad != null) { - document = searcher.doc(scoreDocs[cursor++].doc, fieldsToLoad); - } else { - document = searcher.doc(scoreDocs[cursor++].doc); - } - return transformer.apply(document); - } catch (IOException e) { - throw new QueryException(e); - } - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public void close() {} -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TermElement.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TermElement.java deleted file mode 100644 index c5264f9740..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TermElement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.ConstantImpl; -import com.querydsl.core.types.dsl.StringOperation; - -/** - * {@code TermElement} represents the embedded String as a term - * - * @author tiwe - */ -public class TermElement extends StringOperation { - - private static final long serialVersionUID = 2350215644019186076L; - - public TermElement(String str) { - super(LuceneOps.TERM, ConstantImpl.create(str)); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TypedQuery.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TypedQuery.java deleted file mode 100644 index acbc62b12c..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/TypedQuery.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import java.util.function.Function; -import org.apache.lucene.document.Document; -import org.apache.lucene.search.IndexSearcher; - -/** - * {@code TypedQuery} is a typed query implementation for Lucene queries. - * - *

Converts Lucene documents to typed results via a constructor supplied transformer - * - * @param result type - * @author laim - * @author tiwe - */ -public class TypedQuery extends AbstractLuceneQuery> { - - /** - * Create a new TypedQuery instance - * - * @param searcher index searcher - * @param transformer transformer to transform Lucene documents to result objects - */ - public TypedQuery(IndexSearcher searcher, Function transformer) { - super(searcher, transformer); - } - - /** - * Create a new TypedQuery instance - * - * @param serializer serializer - * @param searcher index searcher - * @param transformer transformer to transform Lucene documents to result objects - */ - public TypedQuery( - LuceneSerializer serializer, IndexSearcher searcher, Function transformer) { - super(serializer, searcher, transformer); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/package-info.java b/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/package-info.java deleted file mode 100644 index 65984f31f8..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/main/java/com/querydsl/lucene5/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Lucene 5 support */ -package com.querydsl.lucene5; diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneQueryTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneQueryTest.java deleted file mode 100644 index 7e30244c3a..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneQueryTest.java +++ /dev/null @@ -1,820 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.easymock.EasyMock.createMockBuilder; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -import com.querydsl.core.NonUniqueResultException; -import com.querydsl.core.QueryException; -import com.querydsl.core.QueryModifiers; -import com.querydsl.core.QueryResults; -import com.querydsl.core.types.ParamNotSetException; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.Param; -import com.querydsl.core.types.dsl.StringPath; -import java.io.IOException; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.DoubleDocValuesField; -import org.apache.lucene.document.DoubleField; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.IntField; -import org.apache.lucene.document.NumericDocValuesField; -import org.apache.lucene.document.SortedDocValuesField; -import org.apache.lucene.document.TextField; -import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.sandbox.queries.DuplicateFilter; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Sort; -import org.apache.lucene.store.RAMDirectory; -import org.apache.lucene.util.BytesRef; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneQuery - * - * @author vema - */ -public class LuceneQueryTest { - - private LuceneQuery query; - private StringPath title; - private NumberPath year; - private NumberPath gross; - - private final StringPath sort = Expressions.stringPath("sort"); - - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - private Field titleField = null; - private SortedDocValuesField titleSortedField; - private TextField authorField = null; - private SortedDocValuesField authorSortedField; - private TextField textField = null; - private IntField yearField = null; - private DoubleField grossField = null; - private SortedDocValuesField textSortedField; - private NumericDocValuesField yearSortedField; - private DoubleDocValuesField grossSortedField; - - private Document createDocument( - final String docTitle, - final String docAuthor, - final String docText, - final int docYear, - final double docGross) { - Document doc = new Document(); - // Reusing field for performance - if (titleField == null) { - titleField = new TextField("title", docTitle, Store.YES); - doc.add(titleField); - titleSortedField = new SortedDocValuesField("title", new BytesRef(docTitle)); - doc.add(titleSortedField); - } else { - titleField.setStringValue(docTitle); - titleSortedField.setBytesValue(new BytesRef(docTitle)); - doc.add(titleField); - doc.add(titleSortedField); - } - if (authorField == null) { - authorField = new TextField("author", docAuthor, Store.YES); - doc.add(authorField); - authorSortedField = new SortedDocValuesField("author", new BytesRef(docAuthor)); - doc.add(authorSortedField); - - } else { - authorField.setStringValue(docAuthor); - authorSortedField.setBytesValue(new BytesRef(docAuthor)); - doc.add(authorField); - doc.add(authorSortedField); - } - if (textField == null) { - textField = new TextField("text", docText, Store.YES); - doc.add(textField); - textSortedField = new SortedDocValuesField("text", new BytesRef(docText)); - doc.add(textSortedField); - } else { - textField.setStringValue(docText); - textSortedField.setBytesValue(new BytesRef(docText)); - doc.add(textField); - doc.add(textSortedField); - } - if (yearField == null) { - yearField = new IntField("year", docYear, Store.YES); - doc.add(yearField); - yearSortedField = new NumericDocValuesField("year", docYear); - doc.add(yearSortedField); - } else { - yearField.setIntValue(docYear); - yearSortedField.setLongValue(docYear); - doc.add(yearField); - doc.add(yearSortedField); - } - - if (grossField == null) { - grossField = new DoubleField("gross", docGross, Store.YES); - doc.add(grossField); - grossSortedField = new DoubleDocValuesField("gross", docGross); - doc.add(grossSortedField); - } else { - grossField.setDoubleValue(docGross); - grossSortedField.setDoubleValue(docGross); - doc.add(grossField); - doc.add(grossSortedField); - } - - return doc; - } - - @Before - public void setUp() throws Exception { - final QDocument entityPath = new QDocument("doc"); - title = entityPath.title; - year = entityPath.year; - gross = entityPath.gross; - - idx = new RAMDirectory(); - writer = createWriter(idx); - - writer.addDocument( - createDocument( - "Jurassic Park", "Michael Crichton", "It's a UNIX system! I know this!", 1990, 90.00)); - writer.addDocument( - createDocument( - "Nummisuutarit", "Aleksis Kivi", "ESKO. Ja iloitset ja riemuitset?", 1864, 10.00)); - writer.addDocument( - createDocument( - "The Lord of the Rings", - "John R. R. Tolkien", - "One Ring to rule them all, One Ring to find them, One Ring to bring them all and in" - + " the darkness bind them", - 1954, - 89.00)); - writer.addDocument( - createDocument( - "Introduction to Algorithms", - "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein", - "Bubble sort", - 1990, - 30.50)); - - writer.close(); - - IndexReader reader = DirectoryReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - } - - private IndexWriter createWriter(RAMDirectory idx) throws Exception { - IndexWriterConfig config = - new IndexWriterConfig(new StandardAnalyzer()) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - return new IndexWriter(idx, config); - } - - @After - public void tearDown() throws Exception { - searcher.getIndexReader().close(); - } - - @Test - public void between() { - assertThat(query.where(year.between(1950, 1990)).fetchCount()).isEqualTo(3); - } - - @Test - public void count_empty_where_clause() { - assertThat(query.fetchCount()).isEqualTo(4); - } - - @Test - public void exists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() > 0).isTrue(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() > 0).isFalse(); - } - - @Test - public void notExists() { - assertThat(query.where(title.eq("Jurassic Park")).fetchCount() == 0).isFalse(); - assertThat(query.where(title.eq("Jurassic Park X")).fetchCount() == 0).isTrue(); - } - - @Test - public void count() { - query.where(title.eq("Jurassic Park")); - assertThat(query.fetchCount()).isEqualTo(1); - } - - @Test(expected = QueryException.class) - @Ignore - public void count_index_problem() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchCount(); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void countDistinct() { - query.where(year.between(1900, 3000)); - assertThat(query.distinct().fetchCount()).isEqualTo(3); - } - - @Test - public void in() { - assertThat(query.where(title.in("Jurassic Park", "Nummisuutarit")).fetchCount()).isEqualTo(2); - } - - @Test - public void in2() { - assertThat(query.where(year.in(1990, 1864)).fetchCount()).isEqualTo(3); - } - - @Test - public void in_toString() { - assertThat(query.where(year.in(1990, 1864)).toString()).isEqualTo("year:`____F year:`____H"); - } - - @Test - public void list_sorted_by_year_ascending() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted() { - query.where(year.between(1800, 2000)); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - @Ignore - // FIXME - public void sorted_by_different_locales() throws Exception { - Document d1 = new Document(); - Document d2 = new Document(); - Document d3 = new Document(); - d1.add(new TextField("sort", "a\u00c4", Store.YES)); - d2.add(new TextField("sort", "ab", Store.YES)); - d3.add(new TextField("sort", "aa", Store.YES)); - writer = createWriter(idx); - writer.addDocument(d1); - writer.addDocument(d2); - writer.addDocument(d3); - writer.close(); - - IndexReader reader = DirectoryReader.open(writer, true); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.ENGLISH), searcher); - assertThat(query.fetch()).hasSize(3); - List results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results).hasSize(3); - assertThat(results.getFirst().getField("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getField("sort").stringValue()).isEqualTo("a\u00c4"); - assertThat(results.get(2).getField("sort").stringValue()).isEqualTo("ab"); - - query = new LuceneQuery(new LuceneSerializer(true, true, Locale.of("fi", "FI")), searcher); - results = query.where(sort.startsWith("a")).orderBy(sort.asc()).fetch(); - assertThat(results.getFirst().getField("sort").stringValue()).isEqualTo("aa"); - assertThat(results.get(1).getField("sort").stringValue()).isEqualTo("ab"); - assertThat(results.get(2).getField("sort").stringValue()).isEqualTo("a\u00c4"); - } - - @Test - public void list_not_sorted_limit_2() { - query.where(year.between(1800, 2000)); - query.limit(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_by_year_limit_1() { - query.where(year.between(1800, 2000)); - query.limit(1); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(1); - } - - @Test - public void list_not_sorted_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - } - - @Test - public void list_sorted_ascending_by_year_offset_2() { - query.where(year.between(1800, 2000)); - query.offset(2); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year_restrict_limit_2_offset_1() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(2); - assertThat(documents.getFirst().get("year")).isEqualTo("1954"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sorted_ascending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_sort() { - Sort sort = LuceneSerializer.DEFAULT.toSort(Collections.singletonList(year.asc())); - - query.where(year.between(1800, 2000)); - // query.orderBy(year.asc()); - query.sort(sort); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1864"); - assertThat(documents.get(1).get("year")).isEqualTo("1954"); - assertThat(documents.get(2).get("year")).isEqualTo("1990"); - assertThat(documents.get(3).get("year")).isEqualTo("1990"); - } - - @Test - public void list_distinct_property() { - assertThat(query.fetch()).hasSize(4); - assertThat(query.distinct(year).fetch()).hasSize(3); - } - - @Test - public void list_with_filter() { - Filter filter = new DuplicateFilter("year"); - assertThat(query.fetch()).hasSize(4); - assertThat(query.filter(filter).fetch()).hasSize(3); - } - - @Test - public void count_distinct_property() { - assertThat(query.fetchCount()).isEqualTo(4L); - assertThat(query.distinct(year).fetchCount()).isEqualTo(3L); - } - - @Test - public void list_sorted_descending_by_year() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.get(2).get("year")).isEqualTo("1954"); - assertThat(documents.get(3).get("year")).isEqualTo("1864"); - } - - @Test - public void list_sorted_descending_by_gross() { - query.where(gross.between(0.0, 1000.00)); - query.orderBy(gross.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("gross")).isEqualTo("90.0"); - assertThat(documents.get(1).get("gross")).isEqualTo("89.0"); - assertThat(documents.get(2).get("gross")).isEqualTo("30.5"); - assertThat(documents.get(3).get("gross")).isEqualTo("10.0"); - } - - @Test - public void list_sorted_descending_by_year_and_ascending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Introduction to Algorithms"); - assertThat(documents.get(1).get("title")).isEqualTo("Jurassic Park"); - } - - @Test - public void list_sorted_descending_by_year_and_descending_by_title() { - query.where(year.between(1800, 2000)); - query.orderBy(year.desc()); - query.orderBy(title.desc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - assertThat(documents.getFirst().get("year")).isEqualTo("1990"); - assertThat(documents.get(1).get("year")).isEqualTo("1990"); - assertThat(documents.getFirst().get("title")).isEqualTo("Jurassic Park"); - assertThat(documents.get(1).get("title")).isEqualTo("Introduction to Algorithms"); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetch(); - verify(searcher); - } - - @Ignore - @Test(expected = QueryException.class) - public void list_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IOException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.orderBy(title.asc()); - query.fetch(); - verify(searcher); - } - - @Test - public void offset() { - assertThat(query.where(title.eq("Jurassic Park")).offset(30).fetch()).isEmpty(); - } - - @Test - public void load_list() { - Document document = query.where(title.ne("")).load(title).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_list_fieldSelector() { - Document document = - query.where(title.ne("")).load(Collections.singleton("title")).fetch().get(0); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult() { - Document document = query.where(title.ne("")).load(title).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void load_singleResult_fieldSelector() { - Document document = query.where(title.ne("")).load(Collections.singleton("title")).fetchFirst(); - assertThat(document.get("title")).isNotNull(); - assertThat(document.get("year")).isNull(); - } - - @Test - public void singleResult() { - assertThat(query.where(title.ne("")).fetchFirst()).isNotNull(); - } - - @Test - public void single_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchFirst().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void single_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchFirst(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void single_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchFirst()).isNull(); - } - - @Test - public void single_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchFirst().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void single_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchFirst().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test(expected = NonUniqueResultException.class) - public void uniqueResult_contract() { - query.where(title.ne("")).fetchOne(); - } - - @Test - public void unique_result_takes_limit() { - assertThat(query.where(title.ne("")).limit(1).fetchOne().get("title")) - .isEqualTo("Jurassic Park"); - } - - @Test - public void unique_result_considers_limit_and_actual_result_size() { - query.where(title.startsWith("Nummi")); - final Document document = query.limit(3).fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void unique_result_returns_null_if_nothing_is_in_range() { - query.where(title.startsWith("Nummi")); - assertThat(query.offset(10).fetchOne()).isNull(); - } - - @Test - public void unique_result_considers_offset() { - assertThat(query.where(title.ne("")).offset(3).fetchOne().get("title")) - .isEqualTo("Introduction to Algorithms"); - } - - @Test - public void unique_result_considers_limit_and_offset() { - assertThat(query.where(title.ne("")).limit(1).offset(2).fetchOne().get("title")) - .isEqualTo("The Lord of the Rings"); - } - - @Test - public void uniqueResult() { - query.where(title.startsWith("Nummi")); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test - public void uniqueResult_with_param() { - final Param param = new Param(String.class, "title"); - query.set(param, "Nummi"); - query.where(title.startsWith(param)); - final Document document = query.fetchOne(); - assertThat(document.get("title")).isEqualTo("Nummisuutarit"); - } - - @Test(expected = ParamNotSetException.class) - public void uniqueResult_param_not_set() { - final Param param = new Param(String.class, "title"); - query.where(title.startsWith(param)); - query.fetchOne(); - } - - @Test(expected = QueryException.class) - public void uniqueResult_finds_more_than_one_result() { - query.where(year.eq(1990)); - query.fetchOne(); - } - - @Test - public void uniqueResult_finds_no_results() { - query.where(year.eq(2200)); - assertThat(query.fetchOne()).isNull(); - } - - @Test - @Ignore - public void uniqueResult_finds_no_results_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchOne()).isNull(); - verify(searcher); - } - - @Test(expected = QueryException.class) - @Ignore - public void uniqueResult_sorted_index_problem_in_max_doc() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andThrow(new IllegalArgumentException()); - replay(searcher); - query.where(title.eq("Jurassic Park")); - query.fetchOne(); - verify(searcher); - } - - @Test - @Ignore - public void count_returns_0_because_no_documents_in_index() throws IOException { - searcher = createMockBuilder(IndexSearcher.class).addMockedMethod("maxDoc").createMock(); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - expect(searcher.getIndexReader().maxDoc()).andReturn(0); - replay(searcher); - assertThat(query.where(year.eq(3000)).fetchCount()).isEqualTo(0); - verify(searcher); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinct() { - query.where(year.between(1900, 2000).or(title.startsWith("Jura"))); - query.orderBy(year.asc()); - final List documents = query.distinct().fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(3); - } - - @Test - public void listResults() { - query.where(year.between(1800, 2000)); - query.restrict(new QueryModifiers(2L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getResults().get(1).get("year")).isEqualTo("1990"); - assertThat(results.getLimit()).isEqualTo(2); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test(expected = UnsupportedOperationException.class) - public void listDistinctResults() { - query.where(year.between(1800, 2000).or(title.eq("The Lord of the Rings"))); - query.restrict(new QueryModifiers(1L, 1L)); - query.orderBy(year.asc()); - final QueryResults results = query.distinct().fetchResults(); - assertThat(results.isEmpty()).isFalse(); - assertThat(results.getResults().get(0).get("year")).isEqualTo("1954"); - assertThat(results.getLimit()).isEqualTo(1); - assertThat(results.getOffset()).isEqualTo(1); - assertThat(results.getTotal()).isEqualTo(4); - } - - @Test - public void list_all() { - final List results = - query.where(title.like("*")).orderBy(title.asc(), year.desc()).fetch(); - assertThat(results).hasSize(4); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_negative() { - query.where(year.between(1800, 2000)); - query.limit(-1); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_limit_0() { - query.where(year.between(1800, 2000)); - query.limit(0); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_sorted_ascending_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.orderBy(year.asc()); - query.fetch(); - } - - @Test(expected = IllegalArgumentException.class) - public void list_not_sorted_offset_negative() { - query.where(year.between(1800, 2000)); - query.offset(-1); - query.fetch(); - } - - @Test - public void list_sorted_ascending_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - query.orderBy(year.asc()); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void list_not_sorted_offset_0() { - query.where(year.between(1800, 2000)); - query.offset(0); - final List documents = query.fetch(); - assertThat(documents).isNotEmpty(); - assertThat(documents).hasSize(4); - } - - @Test - public void iterate() { - query.where(year.between(1800, 2000)); - final Iterator iterator = query.iterate(); - int count = 0; - while (iterator.hasNext()) { - iterator.next(); - ++count; - } - assertThat(count).isEqualTo(4); - } - - @Test - public void all_by_excluding_where() { - assertThat(query.fetch()).hasSize(4); - } - - @Test - public void empty_index_should_return_empty_list() throws Exception { - idx = new RAMDirectory(); - - writer = createWriter(idx); - writer.close(); - IndexReader reader = DirectoryReader.open(idx); - searcher = new IndexSearcher(reader); - query = new LuceneQuery(new LuceneSerializer(true, true), searcher); - assertThat(query.fetch()).isEmpty(); - } - - @Test(expected = QueryException.class) - public void - list_results_throws_an_illegal_argument_exception_when_sum_of_limit_and_offset_is_negative() { - query.limit(1).offset(Integer.MAX_VALUE).fetchResults(); - } - - @Test - public void limit_max_value() { - assertThat(query.limit(Long.MAX_VALUE).fetch()).hasSize(4); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerNotTokenizedTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerNotTokenizedTest.java deleted file mode 100644 index 85e6942296..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerNotTokenizedTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static com.querydsl.lucene5.QPerson.person; -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import java.time.LocalDate; -import java.util.Arrays; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.junit.Before; -import org.junit.Test; - -public class LuceneSerializerNotTokenizedTest { - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - private LuceneSerializer serializer; - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private final Person clooney = new Person("actor_1", "George Clooney", LocalDate.of(1961, 4, 6)); - private final Person pitt = new Person("actor_2", "Brad Pitt", LocalDate.of(1963, 12, 18)); - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - private Document createDocument(Person person) { - Document doc = new Document(); - doc.add(new Field("id", person.getId(), Store.YES, Index.NOT_ANALYZED)); - doc.add(new Field("name", person.getName(), Store.YES, Index.NOT_ANALYZED)); - doc.add( - new Field("birthDate", person.getBirthDate().toString(), Store.YES, Index.NOT_ANALYZED)); - return doc; - } - - @Before - public void before() throws Exception { - serializer = new LuceneSerializer(false, false); - idx = new RAMDirectory(); - IndexWriterConfig config = - new IndexWriterConfig(new StandardAnalyzer()) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument(clooney)); - writer.addDocument(createDocument(pitt)); - - Document document = new Document(); - for (String movie : Arrays.asList("Interview with the Vampire", "Up in the Air")) { - document.add(new Field("movie", movie, Store.YES, Index.NOT_ANALYZED)); - } - writer.addDocument(document); - - writer.close(); - - IndexReader reader = DirectoryReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @Test - public void equals_by_id_matches() throws Exception { - testQuery(person.id.eq("actor_1"), "id:actor_1", 1); - } - - @Test - public void equals_by_id_does_not_match() throws Exception { - testQuery(person.id.eq("actor_8"), "id:actor_8", 0); - } - - @Test - public void equals_by_name_matches() throws Exception { - testQuery(person.name.eq("George Clooney"), "name:George Clooney", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_by_name_ignoring_case_does_not_match() throws Exception { - testQuery(person.name.equalsIgnoreCase("george clooney"), "name:george clooney", 0); - } - - @Test - public void equals_by_name_does_not_match() throws Exception { - testQuery(person.name.eq("George Looney"), "name:George Looney", 0); - } - - @Test - public void starts_with_name_should_match() throws Exception { - testQuery(person.name.startsWith("George C"), "name:George C*", 1); - } - - @Test - public void starts_with_name_should_not_match() throws Exception { - testQuery(person.name.startsWith("George L"), "name:George L*", 0); - } - - @Test - public void ends_with_name_should_match() throws Exception { - testQuery(person.name.endsWith("e Clooney"), "name:*e Clooney", 1); - } - - @Test - public void ends_with_name_should_not_match() throws Exception { - testQuery(person.name.endsWith("e Looney"), "name:*e Looney", 0); - } - - @Test - public void contains_name_should_match() throws Exception { - testQuery(person.name.contains("oney"), "name:*oney*", 1); - } - - @Test - public void contains_name_should_not_match() throws Exception { - testQuery(person.name.contains("bloney"), "name:*bloney*", 0); - } - - @Test - public void in_names_should_match_2() throws Exception { - testQuery( - person.name.in("Brad Pitt", "George Clooney"), "name:Brad Pitt name:George Clooney", 2); - } - - @Test - public void or_by_name_should_match_2() throws Exception { - testQuery( - person.name.eq("Brad Pitt").or(person.name.eq("George Clooney")), - "name:Brad Pitt name:George Clooney", - 2); - } - - @Test - public void equals_by_birth_date() throws Exception { - testQuery(person.birthDate.eq(clooney.getBirthDate()), "birthDate:1961-04-06", 1); - } - - @Test - public void between_phrase() throws Exception { - testQuery( - person.name.between("Brad Pitt", "George Clooney"), - "name:[Brad Pitt TO George Clooney]", - 2); - } - - @Test - public void not_equals_finds_the_actors_and_movies() throws Exception { - testQuery(person.name.ne("Michael Douglas"), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void not_equals_finds_only_clooney_and_movies() throws Exception { - testQuery(person.name.ne("Brad Pitt"), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void and_with_two_not_equals_doesnt_find_the_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").and(person.name.ne("George Clooney")), - "+(-name:Brad Pitt +*:*) +(-name:George Clooney +*:*)", - 1); - } - - @Test - public void or_with_two_not_equals_finds_movies_and_actors() throws Exception { - testQuery( - person.name.ne("Brad Pitt").or(person.name.ne("George Clooney")), - "(-name:Brad Pitt +*:*) (-name:George Clooney +*:*)", - 3); - } - - @Test - public void negation_of_equals_finds_movies_and_actors() throws Exception { - testQuery(person.name.eq("Michael Douglas").not(), "-name:Michael Douglas +*:*", 3); - } - - @Test - public void negation_of_equals_finds_pitt_and_movies() throws Exception { - testQuery(person.name.eq("Brad Pitt").not(), "-name:Brad Pitt +*:*", 2); - } - - @Test - public void multiple_field_search_from_movies() throws Exception { - StringPath movie = Expressions.stringPath("movie"); - testQuery(movie.in("Interview with the Vampire"), "movie:Interview with the Vampire", 1); - testQuery(movie.eq("Up in the Air"), "movie:Up in the Air", 1); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerTest.java deleted file mode 100644 index eeb35d3b10..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/LuceneSerializerTest.java +++ /dev/null @@ -1,718 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -import com.querydsl.core.BooleanBuilder; -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.MatchingFiltersFactory; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.QuerydslModule; -import com.querydsl.core.StringConstant; -import com.querydsl.core.Target; -import com.querydsl.core.types.Expression; -import com.querydsl.core.types.Operation; -import com.querydsl.core.types.Operator; -import com.querydsl.core.types.Ops; -import com.querydsl.core.types.Predicate; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.core.types.dsl.CollectionPath; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.PathBuilder; -import com.querydsl.core.types.dsl.StringPath; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Set; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.DoubleField; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Field.Index; -import org.apache.lucene.document.Field.Store; -import org.apache.lucene.document.FloatField; -import org.apache.lucene.document.IntField; -import org.apache.lucene.document.LongField; -import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexWriterConfig; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.store.RAMDirectory; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -/** - * Tests for LuceneSerializer - * - * @author vema - */ -public class LuceneSerializerTest { - private LuceneSerializer serializer; - private PathBuilder entityPath; - private StringPath title; - private StringPath author; - private StringPath text; - private StringPath rating; - private StringPath publisher; - private NumberPath year; - private NumberPath gross; - private CollectionPath titles; - - private NumberPath longField; - private NumberPath shortField; - private NumberPath byteField; - private NumberPath floatField; - - private static final String YEAR_PREFIX_CODED = ""; - private static final String GROSS_PREFIX_CODED = ""; - private static final String LONG_PREFIX_CODED = ""; - private static final String SHORT_PREFIX_CODED = ""; - private static final String BYTE_PREFIX_CODED = ""; - private static final String FLOAT_PREFIX_CODED = ""; - - private IndexWriterConfig config; - private RAMDirectory idx; - private IndexWriter writer; - private IndexSearcher searcher; - - private static final Set UNSUPPORTED_OPERATORS = - Collections.unmodifiableSet( - EnumSet.of( - Ops.STARTS_WITH_IC, Ops.EQ_IGNORE_CASE, Ops.ENDS_WITH_IC, Ops.STRING_CONTAINS_IC)); - - private final QueryMetadata metadata = new DefaultQueryMetadata(); - - private Document createDocument() { - Document doc = new Document(); - - doc.add(new Field("title", new StringReader("Jurassic Park"))); - doc.add(new Field("author", new StringReader("Michael Crichton"))); - doc.add(new Field("text", new StringReader("It's a UNIX system! I know this!"))); - doc.add(new Field("rating", new StringReader("Good"))); - doc.add(new Field("publisher", "", Store.YES, Index.ANALYZED)); - doc.add(new IntField("year", 1990, Store.YES)); - doc.add(new DoubleField("gross", 900.0, Store.YES)); - - doc.add(new LongField("longField", 1, Store.YES)); - doc.add(new IntField("shortField", 1, Store.YES)); - doc.add(new IntField("byteField", 1, Store.YES)); - doc.add(new FloatField("floatField", 1, Store.YES)); - - return doc; - } - - @Before - public void setUp() throws Exception { - serializer = new LuceneSerializer(true, true); - entityPath = new PathBuilder(Object.class, "obj"); - title = entityPath.getString("title"); - author = entityPath.getString("author"); - text = entityPath.getString("text"); - publisher = entityPath.getString("publisher"); - year = entityPath.getNumber("year", Integer.class); - rating = entityPath.getString("rating"); - gross = entityPath.getNumber("gross", Double.class); - titles = entityPath.getCollection("title", String.class, StringPath.class); - - longField = entityPath.getNumber("longField", Long.class); - shortField = entityPath.getNumber("shortField", Short.class); - byteField = entityPath.getNumber("byteField", Byte.class); - floatField = entityPath.getNumber("floatField", Float.class); - - idx = new RAMDirectory(); - config = - new IndexWriterConfig(new StandardAnalyzer()) - .setOpenMode(IndexWriterConfig.OpenMode.CREATE); - writer = new IndexWriter(idx, config); - - writer.addDocument(createDocument()); - - writer.close(); - - IndexReader reader = DirectoryReader.open(idx); - searcher = new IndexSearcher(reader); - } - - @After - public void tearDown() throws Exception { - searcher.getIndexReader().close(); - } - - private void testQuery(Expression expr, int expectedHits) throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - } - - private void testQuery(Expression expr, String expectedQuery, int expectedHits) - throws Exception { - Query query = serializer.toQuery(expr, metadata); - TopDocs docs = searcher.search(query, 100); - assertThat(docs.totalHits).isEqualTo(expectedHits); - assertThat(query.toString()).isEqualTo(expectedQuery); - } - - @Test - public void queryElement() throws Exception { - Query query1 = serializer.toQuery(author.like("Michael"), metadata); - Query query2 = serializer.toQuery(text.like("Text"), metadata); - - BooleanExpression query = Expressions.anyOf(new QueryElement(query1), new QueryElement(query2)); - testQuery(query, "author:michael text:text", 1); - } - - @Test - public void like() throws Exception { - testQuery(author.like("*ichael*"), "author:*ichael*", 1); - } - - @Test - public void like_custom_wildcard_single_character() throws Exception { - testQuery(author.like("Mi?hael"), "author:mi?hael", 1); - } - - @Test - public void like_custom_wildcard_multiple_character() throws Exception { - testQuery(text.like("*U*X*"), "text:*u*x*", 1); - } - - @Test - public void like_phrase() throws Exception { - testQuery(title.like("*rassic Par*"), "+title:**rassic* +title:*par**", 1); - } - - @Test - public void like_or_like() throws Exception { - testQuery(title.like("House").or(author.like("*ichae*")), "title:house author:*ichae*", 1); - } - - @Test - public void like_and_like() throws Exception { - testQuery(title.like("*assic*").and(rating.like("G?od")), "+title:*assic* +rating:g?od", 1); - } - - @Test - public void eq() throws Exception { - testQuery(rating.eq("good"), "rating:good", 1); - } - - @Test - public void eq_with_deep_path() throws Exception { - StringPath deepPath = entityPath.get("property1", Object.class).getString("property2"); - testQuery(deepPath.eq("good"), "property1.property2:good", 0); - } - - @Test - public void fuzzyLike() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good"), "rating:Good~2", 1); - } - - @Test - public void fuzzyLike_with_similarity() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 2), "rating:Good~2", 1); - } - - @Test - public void fuzzyLike_with_similarity_and_prefix() throws Exception { - testQuery(LuceneExpressions.fuzzyLike(rating, "Good", 2, 0), "rating:Good~2", 1); - } - - @Test - @Ignore - public void eq_numeric_integer() throws Exception { - testQuery(year.eq(1990), "year:" + YEAR_PREFIX_CODED, 1); - } - - @Test - @Ignore - public void eq_numeric_double() throws Exception { - testQuery(gross.eq(900.00), "gross:" + GROSS_PREFIX_CODED, 1); - } - - @Test - @Ignore - public void eq_numeric() throws Exception { - testQuery(longField.eq(1L), "longField:" + LONG_PREFIX_CODED, 1); - testQuery(shortField.eq((short) 1), "shortField:" + SHORT_PREFIX_CODED, 1); - testQuery(byteField.eq((byte) 1), "byteField:" + BYTE_PREFIX_CODED, 1); - testQuery(floatField.eq((float) 1.0), "floatField:" + FLOAT_PREFIX_CODED, 1); - } - - @Test - public void equals_ignores_case() throws Exception { - testQuery(title.eq("Jurassic"), "title:jurassic", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_or_year_equals() throws Exception { - testQuery( - title.equalsIgnoreCase("House").or(year.eq(1990)), - "title:house year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - @Ignore - public void eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)), - "+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED, - 1); - } - - @Test - @Ignore - public void eq_and_eq_and_eq() throws Exception { - testQuery( - title.eq("Jurassic Park").and(year.eq(1990)).and(author.eq("Michael Crichton")), - "+(+title:\"jurassic park\" +year:" + YEAR_PREFIX_CODED + ") +author:\"michael crichton\"", - 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void equals_ignore_case_and_or() throws Exception { - testQuery( - title - .equalsIgnoreCase("Jurassic Park") - .and(rating.equalsIgnoreCase("Bad")) - .or(author.equalsIgnoreCase("Michael Crichton")), - "(+title:\"jurassic park\" +rating:bad) author:\"michael crichton\"", - 1); - } - - @Test - public void eq_or_eq_and_eq_does_not_find_results() throws Exception { - testQuery( - title.eq("jeeves").or(rating.eq("superb")).and(author.eq("michael crichton")), - "+(title:jeeves rating:superb) +author:\"michael crichton\"", - 0); - } - - @Test - public void eq_phrase() throws Exception { - testQuery(title.eq("Jurassic Park"), "title:\"jurassic park\"", 1); - } - - @Test - @Ignore("Not easily done in Lucene!") - public void publisher_equals_empty_string() throws Exception { - testQuery(publisher.eq(""), "publisher:", 1); - } - - @Test - public void eq_phrase_should_not_find_results_but_luceNe_semantics_differs_from_querydsls() - throws Exception { - testQuery(text.eq("UNIX System"), "text:\"unix system\"", 1); - } - - @Test - public void eq_phrase_does_not_find_results_because_word_in_middle() throws Exception { - testQuery(title.eq("Jurassic Amusement Park"), "title:\"jurassic amusement park\"", 0); - } - - @Test - public void like_not_does_not_find_results() throws Exception { - testQuery(title.like("*H*e*").not(), "-title:*h*e* +*:*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void title_equals_ignore_case_negation_or_rating_equals_ignore_case() throws Exception { - testQuery( - title.equalsIgnoreCase("House").not().or(rating.equalsIgnoreCase("Good")), - "-title:house rating:good", - 1); - } - - @Test - public void eq_not_does_not_find_results() throws Exception { - testQuery(title.eq("Jurassic Park").not(), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void title_equals_not_house() throws Exception { - testQuery(title.eq("house").not(), "-title:house +*:*", 1); - } - - @Test - public void eq_and_eq_not_does_not_find_results_because_second_expression_finds_nothing() - throws Exception { - testQuery( - rating.eq("superb").and(title.eq("house").not()), "+rating:superb +(-title:house +*:*)", 0); - } - - @Test - public void not_equals_finds_one() throws Exception { - testQuery(title.ne("house"), "-title:house +*:*", 1); - } - - @Test - public void not_equals_finds_none() throws Exception { - testQuery(title.ne("Jurassic Park"), "-title:\"jurassic park\" +*:*", 0); - } - - @Test - public void nothing_found_with_not_equals_or_equals() throws Exception { - testQuery( - title.ne("jurassic park").or(rating.eq("lousy")), - "(-title:\"jurassic park\" +*:*) rating:lousy", - 0); - } - - @Test - public void ne_and_eq() throws Exception { - testQuery(title.ne("house").and(rating.eq("good")), "+(-title:house +*:*) +rating:good", 1); - } - - @Test - public void startsWith() throws Exception { - testQuery(title.startsWith("Jurassi"), "title:jurassi*", 1); - } - - @Test - public void startsWith_phrase() throws Exception { - testQuery(title.startsWith("jurassic par"), "+title:jurassic* +title:*par*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void starts_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.startsWithIgnoreCase("urassic Par"), "+title:urassic* +title:*par*", 0); - } - - @Test - public void endsWith() throws Exception { - testQuery(title.endsWith("ark"), "title:*ark", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Park"), "+title:*sic* +title:*park", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void ends_with_ignore_case_phrase_does_not_find_results() throws Exception { - testQuery(title.endsWithIgnoreCase("sic Par"), "+title:*sic* +title:*par", 0); - } - - @Test - public void contains() throws Exception { - testQuery(title.contains("rassi"), "title:*rassi*", 1); - } - - @Test(expected = UnsupportedOperationException.class) - public void contains_ignore_case_phrase() throws Exception { - testQuery(title.containsIgnoreCase("rassi Pa"), "+title:*rassi* +title:*pa*", 1); - } - - @Test - public void contains_user_inputted_wildcards_dont_work() throws Exception { - testQuery(title.contains("r*i"), "title:*r\\*i*", 0); - } - - @Test - public void between() throws Exception { - testQuery(title.between("Indiana", "Kundun"), "title:[indiana TO kundun]", 1); - } - - @Test - public void between_numeric_integer() throws Exception { - testQuery(year.between(1980, 2000), "year:[1980 TO 2000]", 1); - } - - @Test - public void between_numeric_double() throws Exception { - testQuery(gross.between(10.00, 19030.00), "gross:[10.0 TO 19030.0]", 1); - } - - @Test - public void between_numeric() throws Exception { - testQuery(longField.between(0L, 2L), "longField:[0 TO 2]", 1); - testQuery(shortField.between((short) 0, (short) 2), "shortField:[0 TO 2]", 1); - testQuery(byteField.between((byte) 0, (byte) 2), "byteField:[0 TO 2]", 1); - testQuery(floatField.between((float) 0.0, (float) 2.0), "floatField:[0.0 TO 2.0]", 1); - } - - @Test - public void between_is_inclusive_from_start() throws Exception { - testQuery(title.between("Jurassic", "Kundun"), "title:[jurassic TO kundun]", 1); - } - - @Test - public void between_is_inclusive_to_end() throws Exception { - testQuery(title.between("Indiana", "Jurassic"), "title:[indiana TO jurassic]", 1); - } - - @Test - public void between_does_not_find_results() throws Exception { - testQuery(title.between("Indiana", "Jurassib"), "title:[indiana TO jurassib]", 0); - } - - @Test - public void in() throws Exception { - testQuery(title.in(Arrays.asList("jurassic", "park")), "title:jurassic title:park", 1); - testQuery(title.in("jurassic", "park"), "title:jurassic title:park", 1); - testQuery(title.eq("jurassic").or(title.eq("park")), "title:jurassic title:park", 1); - } - - @Test - public void lt() throws Exception { - testQuery(rating.lt("Superb"), "rating:{* TO superb}", 1); - } - - @Test - public void lt_numeric_integer() throws Exception { - testQuery(year.lt(1991), "year:{* TO 1991}", 1); - } - - @Test - public void lt_numeric_double() throws Exception { - testQuery(gross.lt(10000.0), "gross:{* TO 10000.0}", 1); - } - - @Test - public void lt_not_in_range_because_equal() throws Exception { - testQuery(rating.lt("Good"), "rating:{* TO good}", 0); - } - - @Test - public void lt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.lt(1990), "year:{* TO 1990}", 0); - } - - @Test - public void lt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.lt(900.0), "gross:{* TO 900.0}", 0); - } - - @Test - public void loe() throws Exception { - testQuery(rating.loe("Superb"), "rating:[* TO superb]", 1); - } - - @Test - public void loe_numeric_integer() throws Exception { - testQuery(year.loe(1991), "year:[* TO 1991]", 1); - } - - @Test - public void loe_numeric_double() throws Exception { - testQuery(gross.loe(903.0), "gross:[* TO 903.0]", 1); - } - - @Test - public void loe_equal() throws Exception { - testQuery(rating.loe("Good"), "rating:[* TO good]", 1); - } - - @Test - public void loe_numeric_integer_equal() throws Exception { - testQuery(year.loe(1990), "year:[* TO 1990]", 1); - } - - @Test - public void loe_numeric_double_equal() throws Exception { - testQuery(gross.loe(900.0), "gross:[* TO 900.0]", 1); - } - - @Test - public void loe_not_found() throws Exception { - testQuery(rating.loe("Bad"), "rating:[* TO bad]", 0); - } - - @Test - public void loe_numeric_integer_not_found() throws Exception { - testQuery(year.loe(1989), "year:[* TO 1989]", 0); - } - - @Test - public void loe_numeric_double_not_found() throws Exception { - testQuery(gross.loe(899.9), "gross:[* TO 899.9]", 0); - } - - @Test - public void gt() throws Exception { - testQuery(rating.gt("Bad"), "rating:{bad TO *}", 1); - } - - @Test - public void gt_numeric_integer() throws Exception { - testQuery(year.gt(1989), "year:{1989 TO *}", 1); - } - - @Test - public void gt_numeric_double() throws Exception { - testQuery(gross.gt(100.00), "gross:{100.0 TO *}", 1); - } - - @Test - public void gt_not_in_range_because_equal() throws Exception { - testQuery(rating.gt("Good"), "rating:{good TO *}", 0); - } - - @Test - public void gt_numeric_integer_not_in_range_because_equal() throws Exception { - testQuery(year.gt(1990), "year:{1990 TO *}", 0); - } - - @Test - public void gt_numeric_double_not_in_range_because_equal() throws Exception { - testQuery(gross.gt(900.00), "gross:{900.0 TO *}", 0); - } - - @Test - public void goe() throws Exception { - testQuery(rating.goe("Bad"), "rating:[bad TO *]", 1); - } - - @Test - public void goe_numeric_integer() throws Exception { - testQuery(year.goe(1989), "year:[1989 TO *]", 1); - } - - @Test - public void goe_numeric_double() throws Exception { - testQuery(gross.goe(320.50), "gross:[320.5 TO *]", 1); - } - - @Test - public void goe_equal() throws Exception { - testQuery(rating.goe("Good"), "rating:[good TO *]", 1); - } - - @Test - public void goe_numeric_integer_equal() throws Exception { - testQuery(year.goe(1990), "year:[1990 TO *]", 1); - } - - @Test - public void goe_numeric_double_equal() throws Exception { - testQuery(gross.goe(900.00), "gross:[900.0 TO *]", 1); - } - - @Test - public void goe_not_found() throws Exception { - testQuery(rating.goe("Hood"), "rating:[hood TO *]", 0); - } - - @Test - public void goe_numeric_integer_not_found() throws Exception { - testQuery(year.goe(1991), "year:[1991 TO *]", 0); - } - - @Test - public void goe_numeric_double_not_found() throws Exception { - testQuery(gross.goe(900.10), "gross:[900.1 TO *]", 0); - } - - @Test - public void equals_empty_string() throws Exception { - testQuery(title.eq(""), "title:", 0); - } - - @Test - public void not_equals_empty_string() throws Exception { - testQuery(title.ne(""), "-title: +*:*", 1); - } - - @Test - public void contains_empty_string() throws Exception { - testQuery(title.contains(""), "title:**", 1); - } - - @Test - public void like_empty_string() throws Exception { - testQuery(title.like(""), "title:", 0); - } - - @Test - public void starts_with_empty_string() throws Exception { - testQuery(title.startsWith(""), "title:*", 1); - } - - @Test - public void ends_with_empty_string() throws Exception { - testQuery(title.endsWith(""), "title:*", 1); - } - - @Test - public void between_empty_strings() throws Exception { - testQuery(title.between("", ""), "title:[ TO ]", 0); - } - - @Test - public void booleanBuilder() throws Exception { - testQuery(new BooleanBuilder(gross.goe(900.10)), "gross:[900.1 TO *]", 0); - } - - @Test - @Ignore - public void fuzzy() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void proximity() throws Exception { - fail("Not yet implemented!"); - } - - @Test - @Ignore - public void boost() throws Exception { - fail("Not yet implemented!"); - } - - @Test - public void pathAny() throws Exception { - testQuery(titles.any().eq("Jurassic"), "title:jurassic", 1); - } - - private boolean unsupportedOperation(Predicate filter) { - return UNSUPPORTED_OPERATORS.contains(((Operation) filter).getOperator()); - } - - @Test - public void various() throws Exception { - MatchingFiltersFactory filters = - new MatchingFiltersFactory(QuerydslModule.LUCENE, Target.LUCENE); - for (Predicate filter : filters.string(title, StringConstant.create("jurassic park"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(author, StringConstant.create("michael crichton"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 1); - } - - for (Predicate filter : filters.string(title, StringConstant.create("1990"))) { - if (unsupportedOperation(filter)) { - continue; - } - testQuery(filter, 0); - } - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/Person.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/Person.java deleted file mode 100644 index 0577368fd8..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/Person.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.annotations.QueryEntity; -import java.time.LocalDate; - -@QueryEntity -public class Person { - private final String id; - private final String name; - private final LocalDate birthDate; - - public Person(String id, String name, LocalDate birthDate) { - this.id = id; - this.name = name; - this.birthDate = birthDate; - } - - public String getId() { - return id; - } - - public LocalDate getBirthDate() { - return birthDate; - } - - public String getName() { - return name; - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/PhraseElementTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/PhraseElementTest.java deleted file mode 100644 index 5e23bfc1fb..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/PhraseElementTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class PhraseElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, false); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:Hello World"); - assertThat(serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - } - - @Test - public void equals() { - PhraseElement el1 = new PhraseElement("x"), - el2 = new PhraseElement("x"), - el3 = new PhraseElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - } - - @Test - public void hashCode_() { - PhraseElement el1 = new PhraseElement("x"), el2 = new PhraseElement("x"); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QDocument.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QDocument.java deleted file mode 100644 index 83b7b4c8ab..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QDocument.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import com.querydsl.core.types.PathMetadataFactory; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import org.apache.lucene.document.Document; - -public class QDocument extends EntityPathBase { - - private static final long serialVersionUID = -4872833626508344081L; - - public QDocument(final String var) { - super(Document.class, PathMetadataFactory.forVariable(var)); - } - - public final NumberPath year = createNumber("year", Integer.class); - - public final StringPath title = createString("title"); - - public final NumberPath gross = createNumber("gross", Double.class); -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QueryElementTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QueryElementTest.java deleted file mode 100644 index 9b3aec786c..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/QueryElementTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.lucene.index.Term; -import org.apache.lucene.search.TermQuery; -import org.junit.Ignore; -import org.junit.Test; - -public class QueryElementTest { - - @Test - @Ignore - public void test() { - QueryElement element = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element.toString()).isEqualTo("str:text"); - // assertEquals(element.getQuery().hashCode(), element.hashCode()); - - QueryElement element2 = new QueryElement(new TermQuery(new Term("str", "text"))); - assertThat(element).isEqualTo(element2); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/TermElementTest.java b/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/TermElementTest.java deleted file mode 100644 index 005e4e7155..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/java/com/querydsl/lucene5/TermElementTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.lucene5; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.DefaultQueryMetadata; -import com.querydsl.core.QueryMetadata; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.StringPath; -import org.junit.Test; - -public class TermElementTest { - - @Test - public void test() { - StringPath title = Expressions.stringPath("title"); - LuceneSerializer serializer = new LuceneSerializer(false, true); - QueryMetadata metadata = new DefaultQueryMetadata(); - assertThat(serializer.toQuery(title.eq("Hello World"), metadata).toString()) - .isEqualTo("title:\"Hello World\""); - assertThat(serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString()) - .isEqualTo("title:Hello World"); - } - - @Test - public void testEqualsAndHashCode() { - TermElement el1 = new TermElement("x"), el2 = new TermElement("x"), el3 = new TermElement("y"); - assertThat(el2).isEqualTo(el1); - assertThat(el1.equals(el3)).isFalse(); - assertThat(el2.hashCode()).isEqualTo(el1.hashCode()); - } -} diff --git a/querydsl-libraries/querydsl-lucene5/src/test/resources/log4j.properties.example b/querydsl-libraries/querydsl-lucene5/src/test/resources/log4j.properties.example deleted file mode 100644 index 0f193f333c..0000000000 --- a/querydsl-libraries/querydsl-lucene5/src/test/resources/log4j.properties.example +++ /dev/null @@ -1,9 +0,0 @@ -# Configure an appender that logs to console -log4j.rootLogger=info, A1 -log4j.threshold=debug -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c{1} - %m%n - -# Configuration of logging levels for different packages -log4j.logger.com.querydsl.lucene5=DEBUG diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/R2DBCMatchingFiltersFactory.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/R2DBCMatchingFiltersFactory.java index 139d8a1580..8d73c6e82f 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/R2DBCMatchingFiltersFactory.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/R2DBCMatchingFiltersFactory.java @@ -97,7 +97,6 @@ public Collection date( rv.add(expr.dayOfMonth().eq(other.dayOfMonth())); if (!target.equals(Target.DERBY) - && !module.equals(QuerydslModule.JDO) && !target.equals(Target.ORACLE) && !target.equals(Target.FIREBIRD) && (!target.equals(Target.POSTGRESQL) || !module.equals(QuerydslModule.JPA))) { @@ -138,7 +137,6 @@ public Collection dateTime( rv.add(expr.dayOfMonth().eq(other.dayOfMonth())); if (!target.equals(Target.DERBY) - && !module.equals(QuerydslModule.JDO) && !target.equals(Target.ORACLE) && (!target.equals(Target.POSTGRESQL) || !module.equals(QuerydslModule.JPA))) { rv.add(expr.dayOfWeek().eq(other.dayOfWeek())); @@ -214,12 +212,10 @@ public > Collection numeric( public Collection string(StringExpression expr, StringExpression other) { var rv = new HashSet(); - if (module != QuerydslModule.LUCENE) { - rv.addAll(comparable(expr, other)); + rv.addAll(comparable(expr, other)); - rv.add(expr.charAt(0).eq(other.charAt(0))); - rv.add(expr.charAt(1).eq(other.charAt(1))); - } + rv.add(expr.charAt(0).eq(other.charAt(0))); + rv.add(expr.charAt(1).eq(other.charAt(1))); rv.add(expr.contains(other)); rv.add(expr.contains(other.substring(0, 1))); @@ -248,58 +244,50 @@ public Collection string(StringExpression expr, StringExpression othe rv.add(expr.eq(other)); rv.add(expr.equalsIgnoreCase(other)); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.indexOf(other).eq(0)); - rv.add(expr.locate(other).eq(1)); - } + rv.add(expr.indexOf(other).eq(0)); + rv.add(expr.locate(other).eq(1)); - if (target != Target.DERBY && module != QuerydslModule.LUCENE) { + if (target != Target.DERBY) { rv.add(expr.indexOf(other.substring(1)).eq(1)); rv.add(expr.indexOf(other.substring(2)).eq(2)); } - if (module != QuerydslModule.LUCENE) { - rv.add(expr.isEmpty().not()); - rv.add(expr.isNotEmpty()); - } + rv.add(expr.isEmpty().not()); + rv.add(expr.isNotEmpty()); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.length().eq(other.length())); - rv.add(expr.like(other)); + rv.add(expr.length().eq(other.length())); + rv.add(expr.like(other)); - if (module != QuerydslModule.JDO || other instanceof Constant) { - rv.add(expr.like(other.substring(0, 1).append("%"))); - rv.add(expr.like(other.substring(0, 1).append("%").append(other.substring(2)))); - rv.add(expr.like(other.substring(1).prepend("%"))); - rv.add(expr.like(other.substring(1, 2).append("%").prepend("%"))); - } + if (other instanceof Constant) { + rv.add(expr.like(other.substring(0, 1).append("%"))); + rv.add(expr.like(other.substring(0, 1).append("%").append(other.substring(2)))); + rv.add(expr.like(other.substring(1).prepend("%"))); + rv.add(expr.like(other.substring(1, 2).append("%").prepend("%"))); } rv.add(expr.lower().eq(other.lower())); - if (module != QuerydslModule.LUCENE) { - if (!module.equals(QuerydslModule.SQL) - || (!target.equals(Target.HSQLDB) - && !target.equals(Target.FIREBIRD) - && !target.equals(Target.H2) - && !target.equals(Target.DB2) - && !target.equals(Target.DERBY) - && !target.equals(Target.SQLITE) - && !target.equals(Target.SQLSERVER))) { - - rv.add(expr.matches(other)); - - if (module != QuerydslModule.JDO || other instanceof Constant) { - rv.add(expr.matches(other.substring(0, 1).append(".*"))); - rv.add(expr.matches(other.substring(0, 1).append(".").append(other.substring(2)))); - rv.add(expr.matches(other.substring(1).prepend(".*"))); - rv.add(expr.matches(other.substring(1, 2).prepend(".*").append(".*"))); - } + if (!module.equals(QuerydslModule.SQL) + || (!target.equals(Target.HSQLDB) + && !target.equals(Target.FIREBIRD) + && !target.equals(Target.H2) + && !target.equals(Target.DB2) + && !target.equals(Target.DERBY) + && !target.equals(Target.SQLITE) + && !target.equals(Target.SQLSERVER))) { + + rv.add(expr.matches(other)); + + if (other instanceof Constant) { + rv.add(expr.matches(other.substring(0, 1).append(".*"))); + rv.add(expr.matches(other.substring(0, 1).append(".").append(other.substring(2)))); + rv.add(expr.matches(other.substring(1).prepend(".*"))); + rv.add(expr.matches(other.substring(1, 2).prepend(".*").append(".*"))); } - - rv.add(expr.ne(other)); } + rv.add(expr.ne(other)); + rv.add(expr.startsWith(other)); rv.add(expr.startsWith(other.substring(0, 1))); rv.add(expr.startsWith(other.substring(0, 2))); @@ -308,13 +296,11 @@ public Collection string(StringExpression expr, StringExpression othe rv.add(expr.startsWithIgnoreCase(other.substring(0, 1))); rv.add(expr.startsWithIgnoreCase(other.substring(0, 2))); - if (module != QuerydslModule.LUCENE) { - rv.add(expr.substring(0, 1).eq(other.substring(0, 1))); - rv.add(expr.substring(1, 2).eq(other.substring(1, 2))); - rv.add(expr.substring(1).eq(other.substring(1))); + rv.add(expr.substring(0, 1).eq(other.substring(0, 1))); + rv.add(expr.substring(1, 2).eq(other.substring(1, 2))); + rv.add(expr.substring(1).eq(other.substring(1))); - rv.add(expr.trim().eq(other.trim())); - } + rv.add(expr.trim().eq(other.trim())); rv.add(expr.upper().eq(other.upper())); return Collections.unmodifiableSet(rv); diff --git a/querydsl-tooling/querydsl-apt/pom.xml b/querydsl-tooling/querydsl-apt/pom.xml index ec636e5724..f381f0d200 100644 --- a/querydsl-tooling/querydsl-apt/pom.xml +++ b/querydsl-tooling/querydsl-apt/pom.xml @@ -34,31 +34,6 @@ - - org.datanucleus - javax.jdo - provided - - - org.springframework.roo - org.springframework.roo.annotations - 1.3.2.RELEASE - provided - - - org.apache.commons - commons-lang3 - - - commons-io - commons-io - - - commons-codec - commons-codec - - - org.mongodb.morphia morphia @@ -160,10 +135,8 @@ src/main/general.xml src/main/hibernate.xml src/main/jakarta.xml - src/main/jdo.xml src/main/jpa.xml src/main/morphia.xml - src/main/roo.xml src/main/onejar.xml ${project.build.directory} @@ -189,8 +162,6 @@ com.querydsl.apt.QuerydslAnnotationProcessor com.querydsl.apt.hibernate.HibernateAnnotationProcessor - com.querydsl.apt.jdo.JDOAnnotationProcessor - com.querydsl.apt.roo.RooAnnotationProcessor diff --git a/querydsl-tooling/querydsl-apt/src/apt/jdo/META-INF/services/javax.annotation.processing.Processor b/querydsl-tooling/querydsl-apt/src/apt/jdo/META-INF/services/javax.annotation.processing.Processor deleted file mode 100644 index ff511957d0..0000000000 --- a/querydsl-tooling/querydsl-apt/src/apt/jdo/META-INF/services/javax.annotation.processing.Processor +++ /dev/null @@ -1 +0,0 @@ -com.querydsl.apt.jdo.JDOAnnotationProcessor \ No newline at end of file diff --git a/querydsl-tooling/querydsl-apt/src/apt/roo/META-INF/services/javax.annotation.processing.Processor b/querydsl-tooling/querydsl-apt/src/apt/roo/META-INF/services/javax.annotation.processing.Processor deleted file mode 100644 index 8ba591975e..0000000000 --- a/querydsl-tooling/querydsl-apt/src/apt/roo/META-INF/services/javax.annotation.processing.Processor +++ /dev/null @@ -1 +0,0 @@ -com.querydsl.apt.roo.RooAnnotationProcessor \ No newline at end of file diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOAnnotationProcessor.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOAnnotationProcessor.java deleted file mode 100644 index 81088431b5..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOAnnotationProcessor.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.apt.jdo; - -import com.querydsl.apt.AbstractQuerydslProcessor; -import com.querydsl.apt.Configuration; -import com.querydsl.core.annotations.QueryEmbedded; -import com.querydsl.core.annotations.QueryEntities; -import com.querydsl.core.annotations.QuerySupertype; -import java.lang.annotation.Annotation; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.jdo.annotations.EmbeddedOnly; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; - -/** - * AnnotationProcessor for JDO which takes {@link PersistenceCapable}, {@link EmbeddedOnly} and - * {@link NotPersistent} into account - * - * @author tiwe - */ -@SupportedAnnotationTypes({"com.querydsl.core.annotations.*", "javax.jdo.annotations.*"}) -public class JDOAnnotationProcessor extends AbstractQuerydslProcessor { - - @Override - protected Configuration createConfiguration(RoundEnvironment roundEnv) { - Class entities = QueryEntities.class; - Class entity = PersistenceCapable.class; - Class superType = QuerySupertype.class; - Class embeddable = EmbeddedOnly.class; - Class embedded = QueryEmbedded.class; - Class skip = NotPersistent.class; - return new JDOConfiguration( - processingEnv, roundEnv, entities, entity, superType, embeddable, embedded, skip); - } -} diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOConfiguration.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOConfiguration.java deleted file mode 100644 index 02e28c513c..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/JDOConfiguration.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.apt.jdo; - -import com.querydsl.apt.DefaultConfiguration; -import com.querydsl.apt.VisitorConfig; -import com.querydsl.codegen.Keywords; -import com.querydsl.core.annotations.QueryInit; -import com.querydsl.core.annotations.QueryTransient; -import com.querydsl.core.annotations.QueryType; -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import javax.annotation.processing.ProcessingEnvironment; -import javax.annotation.processing.RoundEnvironment; -import javax.jdo.annotations.Cacheable; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Columns; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.Extension; -import javax.jdo.annotations.Extensions; -import javax.jdo.annotations.ForeignKey; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.Order; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; -import javax.jdo.annotations.Serialized; -import javax.jdo.annotations.Transactional; -import javax.jdo.annotations.Unique; -import javax.jdo.annotations.Value; -import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.TypeElement; - -/** - * Configuration for {@link JDOAnnotationProcessor} - * - * @author tiwe - * @see JDOAnnotationProcessor - */ -public class JDOConfiguration extends DefaultConfiguration { - - @SuppressWarnings("unchecked") - private static final Iterable> relevantAnnotations = - Collections.unmodifiableList( - Arrays.asList( - Cacheable.class, - Column.class, - Columns.class, - javax.jdo.annotations.Element.class, - Embedded.class, - Extension.class, - Extensions.class, - ForeignKey.class, - Index.class, - Join.class, - Key.class, - NotPersistent.class, - Order.class, - Persistent.class, - PrimaryKey.class, - QueryType.class, - QueryInit.class, - QueryTransient.class, - Serialized.class, - Transactional.class, - Unique.class, - Value.class)); - - public JDOConfiguration( - ProcessingEnvironment processingEnvironment, - RoundEnvironment roundEnv, - Class entitiesAnn, - Class entityAnn, - Class superTypeAnn, - Class embeddableAnn, - Class embeddedAnn, - Class skipAnn) { - super( - processingEnvironment, - roundEnv, - Keywords.JDO, - entitiesAnn, - entityAnn, - superTypeAnn, - embeddableAnn, - embeddedAnn, - skipAnn); - } - - @Override - public VisitorConfig getConfig(TypeElement e, List elements) { - boolean fields = false, methods = false; - for (Element element : elements) { - if (hasRelevantAnnotation(element)) { - fields |= element.getKind().equals(ElementKind.FIELD); - methods |= element.getKind().equals(ElementKind.METHOD); - } - } - return VisitorConfig.get(fields, methods, VisitorConfig.FIELDS_ONLY); - } - - private boolean hasRelevantAnnotation(Element element) { - for (Class relevantAnnotation : relevantAnnotations) { - if (element.getAnnotation(relevantAnnotation) != null) { - return true; - } - } - return false; - } -} diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/package-info.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/package-info.java deleted file mode 100644 index 92a33acd79..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jdo/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** APT JDO support */ -package com.querydsl.apt.jdo; diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/RooAnnotationProcessor.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/RooAnnotationProcessor.java deleted file mode 100644 index 17a7e0e0e6..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/RooAnnotationProcessor.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.apt.roo; - -import com.querydsl.apt.AbstractQuerydslProcessor; -import com.querydsl.apt.Configuration; -import com.querydsl.apt.DefaultConfiguration; -import com.querydsl.apt.jpa.JPAConfiguration; -import jakarta.persistence.Embeddable; -import jakarta.persistence.Embedded; -import jakarta.persistence.MappedSuperclass; -import jakarta.persistence.Transient; -import java.lang.annotation.Annotation; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord; -import org.springframework.roo.addon.jpa.entity.RooJpaEntity; - -/** - * AnnotationProcessor for Spring Roo which takes {@link RooJpaEntity}, {@link RooJpaActiveRecord}, - * {@link MappedSuperclass}, {@link Embeddable} and {@link Transient} into account - * - * @author tiwe - */ -@SupportedAnnotationTypes({ - "com.querydsl.core.annotations.*", - "org.springframework.roo.addon.jpa.entity.*" -}) -public class RooAnnotationProcessor extends AbstractQuerydslProcessor { - - @Override - protected Configuration createConfiguration(RoundEnvironment roundEnv) { - Class entity = RooJpaEntity.class; - Class superType = MappedSuperclass.class; - Class embeddable = Embeddable.class; - Class embedded = Embedded.class; - Class skip = Transient.class; - DefaultConfiguration conf = - new JPAConfiguration( - roundEnv, processingEnv, entity, superType, embeddable, embedded, skip); - conf.setAlternativeEntityAnnotation(RooJpaActiveRecord.class); - return conf; - } -} diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/package-info.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/package-info.java deleted file mode 100644 index 839087dc87..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/roo/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** APT Roo support */ -package com.querydsl.apt.roo; diff --git a/querydsl-tooling/querydsl-apt/src/main/jdo.xml b/querydsl-tooling/querydsl-apt/src/main/jdo.xml deleted file mode 100644 index 016a08ac4d..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/jdo.xml +++ /dev/null @@ -1,19 +0,0 @@ - - jdo - - jar - - false - - - src/apt/jdo - / - - - ${project.build.outputDirectory} - / - - - \ No newline at end of file diff --git a/querydsl-tooling/querydsl-apt/src/main/roo.xml b/querydsl-tooling/querydsl-apt/src/main/roo.xml deleted file mode 100644 index 6e56b67f02..0000000000 --- a/querydsl-tooling/querydsl-apt/src/main/roo.xml +++ /dev/null @@ -1,19 +0,0 @@ - - roo - - jar - - false - - - src/apt/roo - / - - - ${project.build.outputDirectory} - / - - - \ No newline at end of file diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/QuerydslAnnotationProcessorTest.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/QuerydslAnnotationProcessorTest.java index f6aa418f1b..751d3a3857 100644 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/QuerydslAnnotationProcessorTest.java +++ b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/QuerydslAnnotationProcessorTest.java @@ -13,12 +13,8 @@ */ package com.querydsl.apt; -import static org.assertj.core.api.Assertions.assertThat; - import com.querydsl.apt.hibernate.HibernateAnnotationProcessor; -import com.querydsl.apt.jdo.JDOAnnotationProcessor; import com.querydsl.apt.jpa.JPAAnnotationProcessor; -import com.querydsl.apt.roo.RooAnnotationProcessor; import java.io.File; import java.io.IOException; import java.util.Collections; @@ -155,16 +151,4 @@ public void jpaAnnotationProcessor() throws IOException { public void hibernateAnnotationProcessor() throws IOException { process(HibernateAnnotationProcessor.class, CLASSES, "hibernate"); } - - @Test - public void jdoAnnotationProcessor() throws IOException { - process(JDOAnnotationProcessor.class, CLASSES, "jdo"); - } - - @Test - public void rooAnnotationProcessor() throws IOException { - process(RooAnnotationProcessor.class, CLASSES, "roo"); - - assertThat(new File("target/roo/com/querydsl/apt/domain/QRooEntities_MyEntity.java")).exists(); - } } diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/JDOTest.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/JDOTest.java index baf4275d22..d7ac5595b8 100644 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/JDOTest.java +++ b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/JDOTest.java @@ -13,75 +13,14 @@ */ package com.querydsl.apt.domain; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; -import org.junit.Test; +public class JDOTest { -public class JDOTest extends AbstractTest { - - @PersistenceCapable public static class JDOEntity { String prop; - @NotPersistent String skipped; - - @NotPersistent JDOEntity skippedEntity; - } - - @PersistenceCapable - public static class JDOEntity2 { - - private String stringField1; - - private String stringField2; - - public String getStringfield1() { - return stringField1; - } - - public String getStringField2() { - return stringField2; - } - } - - @PersistenceCapable - public static class JDOEntity3 { - - private Integer integerField; - - private String stringField; - - @PrimaryKey - public Integer getId() { - return integerField; - } - - @Persistent - public String getName() { - return stringField; - } - } - - @Test - public void test() throws IllegalAccessException, NoSuchFieldException { - start(QJDOTest_JDOEntity.class, QJDOTest_JDOEntity.jDOEntity); - match(StringPath.class, "prop"); - assertMissing("skipped"); - assertMissing("skippedEntity"); - - start(QJDOTest_JDOEntity2.class, QJDOTest_JDOEntity2.jDOEntity2); - match(StringPath.class, "stringField1"); - assertMissing("stringfield1"); - match(StringPath.class, "stringField2"); + String skipped; - start(QJDOTest_JDOEntity3.class, QJDOTest_JDOEntity3.jDOEntity3); - match(NumberPath.class, "id"); - matchType(Integer.class, "id"); - match(StringPath.class, "name"); + JDOEntity skippedEntity; } } diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QueryProjectionTest.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QueryProjectionTest.java index 6189c97890..c3e459c2a9 100644 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QueryProjectionTest.java +++ b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QueryProjectionTest.java @@ -22,7 +22,6 @@ import com.querydsl.core.types.dsl.StringExpression; import jakarta.persistence.Entity; import java.util.Map; -import javax.jdo.annotations.PersistenceCapable; import org.junit.Test; public class QueryProjectionTest { @@ -30,7 +29,6 @@ public class QueryProjectionTest { // all three annotations are needed, because all are used as entity annotations @QueryEntity @Entity - @PersistenceCapable public static class EntityWithProjection { public EntityWithProjection(long id) {} diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QuerySuperTypeTest.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QuerySuperTypeTest.java deleted file mode 100644 index 29fa750c01..0000000000 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/QuerySuperTypeTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.querydsl.apt.domain; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.querydsl.core.annotations.QuerySupertype; -import java.util.Set; -import javax.jdo.annotations.PersistenceCapable; -import org.junit.Test; - -public class QuerySuperTypeTest { - - @QuerySupertype - public static class Supertype {} - - @PersistenceCapable - public static class JdoEntity { - Set references; - } - - @Test - public void jdoEntity() { - assertThat(QQuerySuperTypeTest_JdoEntity.jdoEntity.references.any().getClass()) - .isEqualTo(QQuerySuperTypeTest_Supertype.class); - } -} diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntities.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntities.java deleted file mode 100644 index e164ba2899..0000000000 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntities.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.querydsl.apt.domain; - -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; -import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord; -import org.springframework.roo.addon.jpa.entity.RooJpaEntity; - -public class RooEntities { - - @RooJpaEntity - public static class MyEntity { - - @Id Long id; - - String name; - - @ManyToOne MyEntity entity; - } - - @RooJpaActiveRecord - public static class MyEntity2 { - - @Id Long id; - - String name; - - @ManyToOne MyEntity entity; - } -} diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntitiesTest.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntitiesTest.java deleted file mode 100644 index 19b4cfb8cc..0000000000 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/RooEntitiesTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.querydsl.apt.domain; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; - -public class RooEntitiesTest { - - @Test - public void rooJpaEntity() { - assertThat(QRooEntities_MyEntity.myEntity).isNotNull(); - } - - @Test - public void rooJpaActiveRecord() { - assertThat(QRooEntities_MyEntity2.myEntity2).isNotNull(); - } -} diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Keywords.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Keywords.java index 83d8579b39..e35ca699b5 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Keywords.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Keywords.java @@ -109,33 +109,4 @@ private Keywords() {} "VALUE", "WHEN", "WHERE")); - - public static final Collection JDO = - Collections.unmodifiableList( - Arrays.asList( - "AS", - "ASC", - "ASCENDING", - "AVG", - "BY", - "COUNT", - "DESC", - "DESCENDING", - "DISTINCT", - "EXCLUDE", - "FROM", - "GROUP", - "HAVING", - "INTO", - "MAX", - "MIN", - "ORDER", - "PARAMETERS", - "RANGE", - "SELECT", - "SUBCLASSES", - "SUM", - "UNIQUE", - "VARIABLES", - "WHERE")); } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/PropertyHandling.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/PropertyHandling.java index c6b99c48b0..30db4e2566 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/PropertyHandling.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/PropertyHandling.java @@ -50,21 +50,6 @@ public Config getConfig(Class type) { return Config.NONE; } }, - /** JDO compatibility */ - JDO { - @Override - public Config getConfig(Class type) { - var fields = false; - var methods = false; - for (Field field : type.getDeclaredFields()) { - fields |= hasAnnotations(field, "javax.jdo.annotations."); - } - for (Method method : type.getDeclaredMethods()) { - methods |= hasAnnotations(method, "javax.jdo.annotations."); - } - return Config.of(fields, methods, Config.FIELDS); - } - }, /** JPA compatibility */ JPA { @Override diff --git a/querydsl-tooling/querydsl-maven-plugin/pom.xml b/querydsl-tooling/querydsl-maven-plugin/pom.xml index 376d6325d2..6f2baf2ed7 100644 --- a/querydsl-tooling/querydsl-maven-plugin/pom.xml +++ b/querydsl-tooling/querydsl-maven-plugin/pom.xml @@ -80,11 +80,6 @@ - - org.datanucleus - javax.jdo - provided - jakarta.persistence jakarta.persistence-api diff --git a/querydsl-tooling/querydsl-maven-plugin/src/main/java/com/querydsl/maven/JDOExporterMojo.java b/querydsl-tooling/querydsl-maven-plugin/src/main/java/com/querydsl/maven/JDOExporterMojo.java deleted file mode 100644 index 967c59f55f..0000000000 --- a/querydsl-tooling/querydsl-maven-plugin/src/main/java/com/querydsl/maven/JDOExporterMojo.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.querydsl.maven; - -import com.querydsl.codegen.GenericExporter; -import com.querydsl.codegen.PropertyHandling; -import jakarta.persistence.Embedded; -import javax.jdo.annotations.EmbeddedOnly; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.ResolutionScope; - -/** - * {@code JDOExporterMojo} calls {@link GenericExporter} using the classpath of the module - * - * @author tiwe - */ -@Mojo(name = "jdo-export", requiresDependencyResolution = ResolutionScope.TEST) -public class JDOExporterMojo extends AbstractExporterMojo { - - @Override - protected void configure(GenericExporter exporter) { - super.configure(exporter); - exporter.setEmbeddableAnnotation(EmbeddedOnly.class); - exporter.setEmbeddedAnnotation(Embedded.class); - exporter.setEntityAnnotation(PersistenceCapable.class); - exporter.setSkipAnnotation(NotPersistent.class); - exporter.setPropertyHandling(PropertyHandling.JDO); - } -} diff --git a/querydsl-tooling/querydsl-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/querydsl-tooling/querydsl-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml index f4fbbca00b..67ddc7d06b 100644 --- a/querydsl-tooling/querydsl-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml +++ b/querydsl-tooling/querydsl-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml @@ -5,7 +5,6 @@ generic-export - jdo-export jpa-export export test-export diff --git a/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/Entity.java b/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/Entity.java index ee6c8dc5a7..ef7d827f55 100644 --- a/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/Entity.java +++ b/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/Entity.java @@ -4,9 +4,7 @@ import jakarta.persistence.Temporal; import jakarta.persistence.TemporalType; import java.util.Date; -import javax.jdo.annotations.PersistenceCapable; -@PersistenceCapable @jakarta.persistence.Entity @QueryEntity public class Entity { diff --git a/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/JDOExporterMojoTest.java b/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/JDOExporterMojoTest.java deleted file mode 100644 index 94235baef7..0000000000 --- a/querydsl-tooling/querydsl-maven-plugin/src/test/java/com/querydsl/maven/JDOExporterMojoTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.querydsl.maven; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.File; -import org.apache.maven.project.MavenProject; -import org.junit.Test; - -public class JDOExporterMojoTest { - - @Test - public void execute() throws Exception { - var mavenProject = new MavenProject(); - mavenProject.getBuild().setOutputDirectory("target/classes"); - mavenProject.getBuild().setTestOutputDirectory("target/test-classes"); - - var mojo = new JDOExporterMojo(); - mojo.setTargetFolder(new File("target/generated-test-data3")); - mojo.setPackages(new String[] {"com.querydsl.maven"}); - mojo.setProject(mavenProject); - mojo.setTestClasspath(true); - mojo.execute(); - - var file = new File("target/generated-test-data3/com/querydsl/maven/QEntity.java"); - assertThat(file).exists(); - } -} From cddd301931ad46b4062663539a6cec70b0d079bd Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 30 Aug 2024 12:48:07 -0300 Subject: [PATCH 2/7] Eliminate mysema.lang dependency Signed-off-by: Marvin Froeder --- pom.xml | 3 +- .../collections/AbstractCollQuery.java | 5 +- .../collections/DefaultQueryEngine.java | 4 +- .../querydsl/collections/GroupBy3Test.java | 2 +- .../com/querydsl/collections/PagingTest.java | 5 +- querydsl-libraries/querydsl-core/pom.xml | 5 -- .../com/querydsl/core/CloseableIterator.java | 58 +++++++++++++++++++ .../java/com/querydsl/core/Fetchable.java | 1 - .../src/main/java/com/querydsl/core/Pair.java | 18 ++++++ .../java/com/querydsl/core/group/GMap.java | 2 +- .../java/com/querydsl/core/group/GroupBy.java | 2 +- .../querydsl/core/group/GroupByBuilder.java | 2 +- .../querydsl/core/group/GroupByIterate.java | 2 +- .../java/com/querydsl/core/group/QPair.java | 2 +- .../core/support/FetchableQueryBase.java | 5 +- .../core/group/AbstractGroupByTest.java | 2 +- .../core/group/GroupByIterateTest.java | 37 ++++++------ .../querydsl/core/group/GroupByListTest.java | 7 +-- .../querydsl/core/group/GroupByMapTest.java | 2 +- .../querydsl/core/support/DummyFetchable.java | 5 +- .../core/types/MappingProjectionTest.java | 2 +- .../querydsl/core/util/MultiIteratorTest.java | 4 +- .../querydsl/core/group/guava/GMultimap.java | 2 +- .../com/querydsl/core/group/guava/GTable.java | 2 +- .../core/group/guava/GuavaGroupBy.java | 2 +- .../com/querydsl/jpa/DefaultQueryHandler.java | 5 +- .../com/querydsl/jpa/EclipseLinkHandler.java | 5 +- .../com/querydsl/jpa/HibernateHandler.java | 5 +- .../java/com/querydsl/jpa/JPASubQuery.java | 2 +- .../java/com/querydsl/jpa/QueryHandler.java | 2 +- .../jpa/ScrollableResultsIterator.java | 2 +- .../querydsl/jpa/TransformingIterator.java | 2 +- .../jpa/hibernate/AbstractHibernateQuery.java | 2 +- .../sql/AbstractHibernateSQLQuery.java | 2 +- .../querydsl/jpa/impl/AbstractJPAQuery.java | 2 +- .../querydsl/jpa/sql/AbstractJPASQLQuery.java | 2 +- .../com/querydsl/jpa/AbstractJPATest.java | 2 +- .../java/com/querydsl/jpa/HibernateBase.java | 2 +- .../querydsl/jpa/HibernateHandlerTest.java | 4 +- .../java/com/querydsl/jpa/QueryHelper.java | 2 +- .../mongodb/AbstractMongodbQuery.java | 2 +- .../AbstractFetchableMongodbQuery.java | 2 +- .../com/querydsl/r2dbc/JDBCTypeMapping.java | 2 +- .../querydsl/r2dbc/group/ReactiveGroupBy.java | 2 +- .../java/com/querydsl/r2dbc/SelectBase.java | 2 +- .../com/querydsl/r2dbc/types/TypeTest.java | 2 +- .../com/querydsl/sql/AbstractSQLQuery.java | 2 +- .../com/querydsl/sql/JDBCTypeMapping.java | 2 +- .../com/querydsl/sql/SQLResultIterator.java | 2 +- .../src/main/java/com/querydsl/sql/Union.java | 2 +- .../main/java/com/querydsl/sql/UnionImpl.java | 2 +- .../com/querydsl/sql/ExtendedSQLQuery.java | 2 +- .../java/com/querydsl/sql/SelectBase.java | 2 +- .../java/com/querydsl/sql/types/TypeTest.java | 2 +- 54 files changed, 157 insertions(+), 93 deletions(-) create mode 100644 querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java create mode 100644 querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Pair.java diff --git a/pom.xml b/pom.xml index 6d9b77b6c1..7d91a220d1 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,8 @@ + true + false UTF-8 http://www.querydsl.com @@ -135,7 +137,6 @@ 3.9.9 33.3.1-jre 0.6.8 - 0.2.4 1.15.10 2.0.16 3.5.2 diff --git a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/AbstractCollQuery.java b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/AbstractCollQuery.java index 27e9639798..362bd8a68a 100644 --- a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/AbstractCollQuery.java +++ b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/AbstractCollQuery.java @@ -13,8 +13,7 @@ */ package com.querydsl.collections; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.FetchableQuery; import com.querydsl.core.JoinType; import com.querydsl.core.NonUniqueResultException; @@ -180,7 +179,7 @@ public

Q leftJoin(MapExpression target, Path

alias) { public CloseableIterator iterate() { @SuppressWarnings("unchecked") // This is the built type var projection = (Expression) queryMixin.getMetadata().getProjection(); - return new IteratorAdapter<>(fetch().iterator()); + return CloseableIterator.of(fetch().iterator()); } @Override diff --git a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java index 9a5cd30f46..73be7ea9c5 100644 --- a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java +++ b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java @@ -13,8 +13,8 @@ */ package com.querydsl.collections; -import com.mysema.commons.lang.IteratorAdapter; import com.querydsl.codegen.utils.Evaluator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.JoinExpression; import com.querydsl.core.JoinType; import com.querydsl.core.QueryMetadata; @@ -166,7 +166,7 @@ private List evaluateSingleSource( if (iterable instanceof List list1) { list = list1; } else { - list = IteratorAdapter.asList(iterable.iterator()); + list = CloseableIterator.asList(iterable.iterator()); } // from & where diff --git a/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/GroupBy3Test.java b/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/GroupBy3Test.java index c41ef643b2..6abc6fd6f4 100644 --- a/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/GroupBy3Test.java +++ b/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/GroupBy3Test.java @@ -7,7 +7,7 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.FetchableQuery; import com.querydsl.core.ResultTransformer; import com.querydsl.core.annotations.QueryEntity; diff --git a/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/PagingTest.java b/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/PagingTest.java index 6bb473c85a..44f11d203c 100644 --- a/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/PagingTest.java +++ b/querydsl-libraries/querydsl-collections/src/test/java/com/querydsl/collections/PagingTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.QueryModifiers; import com.querydsl.core.QueryResults; import com.querydsl.core.types.dsl.Expressions; @@ -55,7 +55,8 @@ private void assertResultSize(int total, int size, QueryModifiers modifiers) { assertThat(createQuery(modifiers).fetchCount()).isEqualTo(total); // via iterator - assertThat(IteratorAdapter.asList(createQuery(modifiers).select(var).iterate())).hasSize(size); + assertThat(CloseableIterator.asList(createQuery(modifiers).select(var).iterate())) + .hasSize(size); } private CollQuery createQuery(QueryModifiers modifiers) { diff --git a/querydsl-libraries/querydsl-core/pom.xml b/querydsl-libraries/querydsl-core/pom.xml index d2a2984917..b4bcb6dd34 100644 --- a/querydsl-libraries/querydsl-core/pom.xml +++ b/querydsl-libraries/querydsl-core/pom.xml @@ -18,11 +18,6 @@ annotations provided - - com.mysema.commons - mysema-commons-lang - ${mysema.lang.version} - io.github.classgraph classgraph diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java new file mode 100644 index 0000000000..bb96f837dc --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/CloseableIterator.java @@ -0,0 +1,58 @@ +package com.querydsl.core; + +import java.util.Iterator; +import java.util.List; +import java.util.Spliterator; +import java.util.Spliterators; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + +public interface CloseableIterator extends Iterator, AutoCloseable { + + @Override + void close(); + + public static List asList(CloseableIterator iterator) { + try (iterator) { + return StreamSupport.stream( + Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false) + .collect(Collectors.toList()); + } + } + + public static CloseableIterator of(Iterator iterator) { + return of(iterator, () -> {}); + } + + public static CloseableIterator of(CloseableIterator iterator) { + return of(iterator, iterator); + } + + public static CloseableIterator of(Iterator iterator, AutoCloseable closeable) { + return new CloseableIterator() { + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public E next() { + return iterator.next(); + } + + @Override + public void close() { + try { + closeable.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + + public static List asList(Iterator iterator) { + return asList(of(iterator)); + } +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Fetchable.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Fetchable.java index eaa6432087..5b706a0776 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Fetchable.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Fetchable.java @@ -13,7 +13,6 @@ */ package com.querydsl.core; -import com.mysema.commons.lang.CloseableIterator; import java.util.List; import java.util.Spliterator; import java.util.Spliterators; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Pair.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Pair.java new file mode 100644 index 0000000000..864ad82a21 --- /dev/null +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/Pair.java @@ -0,0 +1,18 @@ +package com.querydsl.core; + +public record Pair(F first, S second) { + + @Deprecated + public F getFirst() { + return first(); + } + + @Deprecated + public S getSecond() { + return second(); + } + + public static Pair of(T key, U value) { + return new Pair<>(key, value); + } +} diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GMap.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GMap.java index d6018919ec..532a39bc3a 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GMap.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GMap.java @@ -13,7 +13,7 @@ */ package com.querydsl.core.group; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import java.io.Serial; import java.util.Comparator; import java.util.HashMap; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java index 4f1d0f6de2..4030c189e6 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupBy.java @@ -13,7 +13,7 @@ */ package com.querydsl.core.group; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.ResultTransformer; import com.querydsl.core.types.Expression; import com.querydsl.core.types.Projections; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByBuilder.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByBuilder.java index 8b68f1bc51..9c442fea89 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByBuilder.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByBuilder.java @@ -13,7 +13,7 @@ */ package com.querydsl.core.group; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.ResultTransformer; import com.querydsl.core.types.Expression; import com.querydsl.core.types.FactoryExpression; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByIterate.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByIterate.java index d7f0d8899b..3c34a379ba 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByIterate.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupByIterate.java @@ -15,7 +15,7 @@ import static com.querydsl.core.util.TupleUtils.toTuple; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.FetchableQuery; import com.querydsl.core.Tuple; import com.querydsl.core.types.Expression; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/QPair.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/QPair.java index 99a78ef01b..da09472666 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/QPair.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/QPair.java @@ -13,7 +13,7 @@ */ package com.querydsl.core.group; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.types.ConstructorExpression; import com.querydsl.core.types.Expression; import java.io.Serial; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java index 603a140f8e..60703dd501 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java @@ -13,8 +13,7 @@ */ package com.querydsl.core.support; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.Fetchable; import com.querydsl.core.FetchableQuery; import com.querydsl.core.NonUniqueResultException; @@ -40,7 +39,7 @@ public FetchableQueryBase(QueryMixin queryMixin) { @Override public List fetch() { - return IteratorAdapter.asList(iterate()); + return CloseableIterator.asList(iterate()); } @Override diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/AbstractGroupByTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/AbstractGroupByTest.java index 30a5478d18..02a30fe862 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/AbstractGroupByTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/AbstractGroupByTest.java @@ -1,6 +1,6 @@ package com.querydsl.core.group; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.Tuple; import com.querydsl.core.support.DummyFetchableQuery; import com.querydsl.core.types.ConstructorExpression; diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByIterateTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByIterateTest.java index 600145cda8..8ea207b16a 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByIterateTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByIterateTest.java @@ -19,9 +19,8 @@ import static com.querydsl.core.group.GroupBy.set; import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.Pair; import com.querydsl.core.Tuple; import com.querydsl.core.types.Projections; import java.util.Arrays; @@ -41,7 +40,7 @@ public class GroupByIterateTest extends AbstractGroupByTest { public void group_order() { CloseableIterator resultsIt = BASIC_RESULTS.transform(groupBy(postId).iterate(postName, set(commentId))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); } @@ -52,7 +51,7 @@ public void first_set_and_list() { CloseableIterator resultsIt = BASIC_RESULTS.transform( groupBy(postId).iterate(postName, set(commentId), list(commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -70,7 +69,7 @@ public void group_by_null() { CloseableIterator resultsIt = BASIC_RESULTS.transform( groupBy(postId).iterate(postName, set(commentId), list(commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -87,7 +86,7 @@ public void noSuchElementException() { CloseableIterator resultsIt = BASIC_RESULTS.transform( groupBy(postId).iterate(postName, set(commentId), list(commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -101,7 +100,7 @@ public void classCastException() { CloseableIterator resultsIt = BASIC_RESULTS.transform( groupBy(postId).iterate(postName, set(commentId), list(commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -114,7 +113,7 @@ public void classCastException() { public void map1() { CloseableIterator resultsIt = MAP_RESULTS.transform(groupBy(postId).iterate(postName, map(commentId, commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -128,7 +127,7 @@ public void map1() { public void map2() { CloseableIterator> resultsIt = MAP2_RESULTS.transform(groupBy(postId).iterate(map(commentId, commentText))); - List> results = IteratorAdapter.asList(resultsIt); + List> results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -140,7 +139,7 @@ public void map2() { public void map22() { CloseableIterator> results = MAP2_RESULTS.transform(groupBy(postId).iterate(map(commentId, commentText))); - List> actual = IteratorAdapter.asList(results); + List> actual = CloseableIterator.asList(results); Object commentId = null; Map comments = null; @@ -168,7 +167,7 @@ public void map22() { public void map3() { CloseableIterator>> results = MAP3_RESULTS.transform(groupBy(postId).iterate(map(postId, map(commentId, commentText)))); - List>> actual = IteratorAdapter.asList(results); + List>> actual = CloseableIterator.asList(results); Object postId = null; Map> posts = null; @@ -197,7 +196,7 @@ public void map3() { public void map4() { CloseableIterator, String>> results = MAP4_RESULTS.transform(groupBy(postId).iterate(map(map(postId, commentText), postName))); - List, String>> actual = IteratorAdapter.asList(results); + List, String>> actual = CloseableIterator.asList(results); Object commentId = null; Map, String> comments = null; @@ -227,7 +226,7 @@ public void array_access() { CloseableIterator resultsIt = BASIC_RESULTS.transform( groupBy(postId).iterate(postName, set(commentId), list(commentText))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -246,7 +245,7 @@ public void transform_results() { POST_W_COMMENTS.transform( groupBy(postId) .iterate(Projections.constructor(Post.class, postId, postName, set(qComment)))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -265,7 +264,7 @@ public void transform_as_bean() { groupBy(postId) .iterate( Projections.bean(Post.class, postId, postName, set(qComment).as("comments")))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(4); @@ -287,7 +286,7 @@ public void oneToOneToMany_projection() { User.class, userName, Projections.constructor(Post.class, postId, postName, set(qComment))))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(2); @@ -310,7 +309,7 @@ public void oneToOneToMany_projection_as_bean() { userName, Projections.bean(Post.class, postId, postName, set(qComment).as("comments")) .as("latestPost")))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(2); @@ -333,7 +332,7 @@ public void oneToOneToMany_projection_as_bean_and_constructor() { userName, Projections.constructor(Post.class, postId, postName, set(qComment)) .as("latestPost")))); - List results = IteratorAdapter.asList(resultsIt); + List results = CloseableIterator.asList(resultsIt); assertThat(results).hasSize(2); diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByListTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByListTest.java index c08e3e067b..3ca4a688a9 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByListTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByListTest.java @@ -19,9 +19,8 @@ import static com.querydsl.core.group.GroupBy.set; import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.CloseableIterator; +import com.querydsl.core.Pair; import com.querydsl.core.Tuple; import com.querydsl.core.types.Projections; import java.util.Arrays; @@ -174,7 +173,7 @@ private Map> findPostsById( public void map4() { CloseableIterator, String>> results = MAP4_RESULTS.transform(groupBy(postId).iterate(map(map(postId, commentText), postName))); - List, String>> actual = IteratorAdapter.asList(results); + List, String>> actual = CloseableIterator.asList(results); Object commentId = null; Map, String> comments = null; diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByMapTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByMapTest.java index 16e4e781c6..0924833123 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByMapTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/group/GroupByMapTest.java @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.ResultTransformer; import com.querydsl.core.Tuple; import com.querydsl.core.types.Projections; diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/support/DummyFetchable.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/support/DummyFetchable.java index 8141defd06..1cce406c6b 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/support/DummyFetchable.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/support/DummyFetchable.java @@ -1,7 +1,6 @@ package com.querydsl.core.support; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.Fetchable; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryModifiers; @@ -19,7 +18,7 @@ public DummyFetchable(List results) { @Override public CloseableIterator iterate() { - return new IteratorAdapter<>(results.iterator()); + return CloseableIterator.of(results.iterator()); } @Override diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/types/MappingProjectionTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/types/MappingProjectionTest.java index 84d1c1133f..8a5c1d5933 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/types/MappingProjectionTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/types/MappingProjectionTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.Tuple; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.StringPath; diff --git a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/util/MultiIteratorTest.java b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/util/MultiIteratorTest.java index 3e3479426a..ab35d59a2e 100644 --- a/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/util/MultiIteratorTest.java +++ b/querydsl-libraries/querydsl-core/src/test/java/com/querydsl/core/util/MultiIteratorTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -117,7 +117,7 @@ public void test() { List list1 = asList(1, 2, 3, 4); List list2 = asList(10, 20, 30); var iterator = new MultiIterator<>(asList(list1, list2)); - List list = IteratorAdapter.asList(iterator); + List list = CloseableIterator.asList(iterator); assertThat(asList(list.getFirst())).isEqualTo(asList(1, 10)); assertThat(asList(list.get(1))).isEqualTo(asList(1, 20)); diff --git a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GMultimap.java b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GMultimap.java index 7e9a5299cb..798aac772d 100644 --- a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GMultimap.java +++ b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GMultimap.java @@ -17,7 +17,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.group.AbstractGroupExpression; import com.querydsl.core.group.GroupCollector; import com.querydsl.core.group.GroupExpression; diff --git a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GTable.java b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GTable.java index 86cf3b0b66..8a7aab40fd 100644 --- a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GTable.java +++ b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GTable.java @@ -16,7 +16,7 @@ import com.google.common.collect.HashBasedTable; import com.google.common.collect.Table; import com.google.common.collect.TreeBasedTable; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.group.AbstractGroupExpression; import com.querydsl.core.group.GroupCollector; import com.querydsl.core.group.GroupExpression; diff --git a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GuavaGroupBy.java b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GuavaGroupBy.java index 5540319c86..5b7e0c65a6 100644 --- a/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GuavaGroupBy.java +++ b/querydsl-libraries/querydsl-guava/src/main/java/com/querydsl/core/group/guava/GuavaGroupBy.java @@ -17,7 +17,7 @@ import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.Table; import com.google.common.collect.TreeBasedTable; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.ResultTransformer; import com.querydsl.core.group.AbstractGroupExpression; import com.querydsl.core.group.GroupBy; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java index 233991a4c3..28ae1d81a8 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/DefaultQueryHandler.java @@ -13,8 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import jakarta.persistence.Query; import java.util.Iterator; @@ -53,7 +52,7 @@ public CloseableIterator iterate( if (projection != null) { return new TransformingIterator<>(iterator, projection); } else { - return new IteratorAdapter<>(iterator); + return CloseableIterator.of(iterator); } } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/EclipseLinkHandler.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/EclipseLinkHandler.java index eacef47c87..fe4e028ef1 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/EclipseLinkHandler.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/EclipseLinkHandler.java @@ -13,8 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import jakarta.persistence.PersistenceException; import jakarta.persistence.Query; @@ -96,7 +95,7 @@ public T next() { if (projection != null) { return new TransformingIterator<>(iterator, closeable, projection); } else { - return new IteratorAdapter<>(iterator, closeable); + return CloseableIterator.of(iterator, closeable); } } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/HibernateHandler.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/HibernateHandler.java index 5c53754467..c014f9599e 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/HibernateHandler.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/HibernateHandler.java @@ -13,8 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import jakarta.persistence.PersistenceException; import jakarta.persistence.Query; @@ -63,7 +62,7 @@ public CloseableIterator iterate(Query query, FactoryExpression projec if (projection != null) { return new TransformingIterator<>(iterator, projection); } else { - return new IteratorAdapter<>(iterator); + return CloseableIterator.of(iterator); } } } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPASubQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPASubQuery.java index d10bf1b1c1..44f5a50848 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPASubQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPASubQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/QueryHandler.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/QueryHandler.java index 833c218e7c..2c2e087110 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/QueryHandler.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/QueryHandler.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import jakarta.persistence.Query; import java.util.stream.Stream; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java index 402aea4c67..4be986252d 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/ScrollableResultsIterator.java @@ -10,7 +10,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java index 76e013cf2f..9db5f0ff5a 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import java.io.Closeable; import java.io.IOException; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java index d4842c2440..04fb83ebff 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/AbstractHibernateQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa.hibernate; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryException; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/sql/AbstractHibernateSQLQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/sql/AbstractHibernateSQLQuery.java index 854d8b3d1d..105102753b 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/sql/AbstractHibernateSQLQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/sql/AbstractHibernateSQLQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa.hibernate.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java index e7fa43851a..22bba4d1f4 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa.impl; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/sql/AbstractJPASQLQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/sql/AbstractJPASQLQuery.java index 36752634cb..c8976cf1c6 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/sql/AbstractJPASQLQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/sql/AbstractJPASQLQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java index 6f22696422..b5dc1a431d 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java @@ -24,10 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -import com.mysema.commons.lang.Pair; import com.querydsl.core.Fetchable; import com.querydsl.core.FilterFactory; import com.querydsl.core.MatchingFiltersFactory; +import com.querydsl.core.Pair; import com.querydsl.core.ProjectionsFactory; import com.querydsl.core.QueryExecution; import com.querydsl.core.QuerydslModule; diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java index 4b2871944d..2d75cb555e 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.Target; import com.querydsl.core.Tuple; diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateHandlerTest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateHandlerTest.java index b10d025ac8..503429e745 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateHandlerTest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateHandlerTest.java @@ -8,7 +8,7 @@ import static org.easymock.EasyMock.verify; import static org.hibernate.ScrollMode.FORWARD_ONLY; -import com.mysema.commons.lang.IteratorAdapter; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.types.FactoryExpression; import com.querydsl.jpa.domain4.Library; import jakarta.persistence.PersistenceException; @@ -119,7 +119,7 @@ public void should_return_iterator_adapter_when_call_iterate_function() { expect(queryResultList.iterator()).andReturn(iterator); replay(query); - assertThat(hibernateHandler.iterate(query, null).getClass()).isEqualTo(IteratorAdapter.class); + assertThat(hibernateHandler.iterate(query, null)).isInstanceOf(CloseableIterator.class); } @Test diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/QueryHelper.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/QueryHelper.java index 5a01c6e1bb..bc3e664bd2 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/QueryHelper.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/QueryHelper.java @@ -13,7 +13,7 @@ */ package com.querydsl.jpa; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/AbstractMongodbQuery.java b/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/AbstractMongodbQuery.java index 78190fec2a..8696b11afa 100644 --- a/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/AbstractMongodbQuery.java +++ b/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/AbstractMongodbQuery.java @@ -18,7 +18,7 @@ import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mongodb.ReadPreference; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.Fetchable; import com.querydsl.core.JoinExpression; diff --git a/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/document/AbstractFetchableMongodbQuery.java b/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/document/AbstractFetchableMongodbQuery.java index 8d79eb2936..f682df6ac1 100644 --- a/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/document/AbstractFetchableMongodbQuery.java +++ b/querydsl-libraries/querydsl-mongodb/src/main/java/com/querydsl/mongodb/document/AbstractFetchableMongodbQuery.java @@ -17,7 +17,7 @@ import com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.Fetchable; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.QueryModifiers; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/JDBCTypeMapping.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/JDBCTypeMapping.java index c4523154a5..1b6c06f3c8 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/JDBCTypeMapping.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/JDBCTypeMapping.java @@ -13,7 +13,7 @@ */ package com.querydsl.r2dbc; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.sql.types.Null; import io.r2dbc.spi.Blob; import java.math.BigDecimal; diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupBy.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupBy.java index e943127c74..c15df6151f 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupBy.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/group/ReactiveGroupBy.java @@ -13,7 +13,7 @@ */ package com.querydsl.r2dbc.group; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.core.ResultTransformer; import com.querydsl.core.group.AbstractGroupExpression; import com.querydsl.core.group.GAvg; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java index f3ae940b38..3bd38cd34c 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SelectBase.java @@ -37,8 +37,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import com.google.common.collect.Maps; -import com.mysema.commons.lang.Pair; import com.querydsl.core.NonUniqueResultException; +import com.querydsl.core.Pair; import com.querydsl.core.QueryException; import com.querydsl.core.QuerydslModule; import com.querydsl.core.ReactiveFetchable; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/types/TypeTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/types/TypeTest.java index cdcd5685f5..2714e3b802 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/types/TypeTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/types/TypeTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.r2dbc.binding.BindMarkersFactory; import com.querydsl.r2dbc.binding.BindTarget; import com.querydsl.r2dbc.binding.StatementWrapper; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java index 16208d07f8..109be7e45f 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.QueryException; import com.querydsl.core.QueryFlag; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/JDBCTypeMapping.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/JDBCTypeMapping.java index af02dae9cb..b11698c0ab 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/JDBCTypeMapping.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/JDBCTypeMapping.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import com.querydsl.sql.types.Null; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLResultIterator.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLResultIterator.java index d1385df9c4..4326a16dee 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLResultIterator.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLResultIterator.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.QueryException; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Union.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Union.java index ae14fb9745..6ed4c2441b 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Union.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/Union.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.Fetchable; import com.querydsl.core.types.Expression; import com.querydsl.core.types.OrderSpecifier; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/UnionImpl.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/UnionImpl.java index bc53a62d97..7750ad56e5 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/UnionImpl.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/UnionImpl.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.NonUniqueResultException; import com.querydsl.core.Query; import com.querydsl.core.QueryMetadata; diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/ExtendedSQLQuery.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/ExtendedSQLQuery.java index df4434992c..76728d6843 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/ExtendedSQLQuery.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/ExtendedSQLQuery.java @@ -13,7 +13,7 @@ */ package com.querydsl.sql; -import com.mysema.commons.lang.CloseableIterator; +import com.querydsl.core.CloseableIterator; import com.querydsl.core.DefaultQueryMetadata; import com.querydsl.core.QueryMetadata; import com.querydsl.core.QueryResults; diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java index 8a115b2261..1900fc2c7f 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java @@ -38,9 +38,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.mysema.commons.lang.Pair; import com.querydsl.core.Fetchable; import com.querydsl.core.NonUniqueResultException; +import com.querydsl.core.Pair; import com.querydsl.core.QueryException; import com.querydsl.core.QueryExecution; import com.querydsl.core.QuerydslModule; diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/types/TypeTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/types/TypeTest.java index 02953cb216..b50135c6cf 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/types/TypeTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/types/TypeTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import com.mysema.commons.lang.Pair; +import com.querydsl.core.Pair; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; From a4f4a54715a81a14fe338fa45dfe67e259187a0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:10:49 +0000 Subject: [PATCH 3/7] Bump spring.version from 6.2.0 to 6.2.1 Bumps `spring.version` from 6.2.0 to 6.2.1. Updates `org.springframework:spring-jdbc` from 6.2.0 to 6.2.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.2.0...v6.2.1) Updates `org.springframework:spring-test` from 6.2.0 to 6.2.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.2.0...v6.2.1) Updates `org.springframework:spring-context` from 6.2.0 to 6.2.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.2.0...v6.2.1) Updates `org.springframework:spring-aop` from 6.2.0 to 6.2.1 - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](https://github.com/spring-projects/spring-framework/compare/v6.2.0...v6.2.1) --- updated-dependencies: - dependency-name: org.springframework:spring-jdbc dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-test dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-context dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.springframework:spring-aop dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f71e10eec3..e29ecf3571 100644 --- a/pom.xml +++ b/pom.xml @@ -105,7 +105,7 @@ 3.33.0 3.2.1 3.4.0 - 6.2.0 + 6.2.1 12.1.0.0 From 498c6de86511d742f6cdafec2f0ec548b923dce5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:11:33 +0000 Subject: [PATCH 4/7] Bump org.openrewrite.maven:rewrite-maven-plugin from 5.46.2 to 5.46.3 Bumps [org.openrewrite.maven:rewrite-maven-plugin](https://github.com/openrewrite/rewrite-maven-plugin) from 5.46.2 to 5.46.3. - [Release notes](https://github.com/openrewrite/rewrite-maven-plugin/releases) - [Commits](https://github.com/openrewrite/rewrite-maven-plugin/compare/v5.46.2...v5.46.3) --- updated-dependencies: - dependency-name: org.openrewrite.maven:rewrite-maven-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f71e10eec3..aae8e2501a 100644 --- a/pom.xml +++ b/pom.xml @@ -1009,7 +1009,7 @@ org.openrewrite.maven rewrite-maven-plugin - 5.46.2 + 5.46.3 From 28b0d8b2ee0ba55406e55565ebc08799072f84df Mon Sep 17 00:00:00 2001 From: Nova Date: Fri, 13 Dec 2024 11:14:04 -0800 Subject: [PATCH 5/7] Kotlin KSP Nullability Fix (#718) When using nullable types in JPA Entity fields, the type determination code was throwing exceptions. This change creates a local version of the KSType.toClassName() function which gets the ClassName while ignoring the KSType's nullability and parameterization. It also ensures that the ClassName returned does not include a nullability modifier as it previously did with Enums. --- .../kotlin/com/querydsl/example/ksp/Cat.kt | 12 ++++- .../com/querydsl/example/ksp/CatType.kt | 6 +++ .../kotlin/com/querydsl/example/ksp/Person.kt | 4 ++ .../src/test/kotlin/Tests.kt | 45 ++++++++++++++++++- .../com/querydsl/ksp/codegen/TypeExtractor.kt | 20 +++++++-- 5 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/CatType.kt diff --git a/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Cat.kt b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Cat.kt index 789088053c..aa0e38ec64 100644 --- a/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Cat.kt +++ b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Cat.kt @@ -1,12 +1,22 @@ package com.querydsl.example.ksp import jakarta.persistence.Entity +import jakarta.persistence.Enumerated +import jakarta.persistence.EnumType import jakarta.persistence.Id +import jakarta.persistence.ManyToOne @Entity class Cat( @Id val id: Int, val name: String, - val isTailUpright: Boolean + val isTailUpright: Boolean, + val fluffiness: String? = null, + + @ManyToOne + val owner: Person? = null, + + @Enumerated(EnumType.STRING) + val catType: CatType? = CatType.HOUSE, ) diff --git a/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/CatType.kt b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/CatType.kt new file mode 100644 index 0000000000..eecd52a5c7 --- /dev/null +++ b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/CatType.kt @@ -0,0 +1,6 @@ +package com.querydsl.example.ksp + +enum class CatType { + HOUSE, + MAINE_COON +} diff --git a/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Person.kt b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Person.kt index c560865078..1676c9d922 100644 --- a/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Person.kt +++ b/querydsl-examples/querydsl-example-ksp-codegen/src/main/kotlin/com/querydsl/example/ksp/Person.kt @@ -2,10 +2,14 @@ package com.querydsl.example.ksp import jakarta.persistence.Entity import jakarta.persistence.Id +import jakarta.persistence.OneToMany @Entity class Person( @Id val id: Int, val name: String, + + @OneToMany(mappedBy = "owner") + val cats: List? = null, ) diff --git a/querydsl-examples/querydsl-example-ksp-codegen/src/test/kotlin/Tests.kt b/querydsl-examples/querydsl-example-ksp-codegen/src/test/kotlin/Tests.kt index 4355e1204b..a847f8b89e 100644 --- a/querydsl-examples/querydsl-example-ksp-codegen/src/test/kotlin/Tests.kt +++ b/querydsl-examples/querydsl-example-ksp-codegen/src/test/kotlin/Tests.kt @@ -1,4 +1,5 @@ import com.querydsl.example.ksp.Cat +import com.querydsl.example.ksp.CatType import com.querydsl.example.ksp.Person import com.querydsl.example.ksp.QCat import com.querydsl.example.ksp.QPerson @@ -40,6 +41,39 @@ class Tests { } } + @Test + fun `create cat with owner` () { + val emf = initialize() + + run { + val em = emf.createEntityManager() + em.transaction.begin() + val catOwner = Person(425, "Percy Bysshe Catownerly") + em.persist(catOwner) + em.persist(Cat(103, "Samuel Taylor Cattingridge", false, "Not so fluffy", catOwner, CatType.MAINE_COON)) + em.transaction.commit() + em.close() + } + + run { + val em = emf.createEntityManager() + val queryFactory = JPAQueryFactory(em) + val q = QCat.cat + val catWithOwner = queryFactory + .selectFrom(q) + .where(q.name.eq("Samuel Taylor Cattingridge")) + .fetchOne() + if (catWithOwner == null) { + fail("No owned cat was returned") + } else { + assertThat(catWithOwner.id).isEqualTo(103) + assertThat(catWithOwner.catType).isEqualTo(CatType.MAINE_COON) + assertThat(catWithOwner.owner?.id).isEqualTo(425) + } + em.close() + } + } + @Test fun `filter entities`() { val emf = initialize() @@ -47,8 +81,8 @@ class Tests { run { val em = emf.createEntityManager() em.transaction.begin() - em.persist(Cat(100, "Neville Furbottom", true)) - em.persist(Cat(101, "Edgar Allan Paw", true)) + em.persist(Cat(100, "Neville Furbottom", true, "Quite Fluffy")) + em.persist(Cat(101, "Edgar Allan Paw", true, null)) em.persist(Cat(102, "Admiral Meowington", false)) em.transaction.commit() em.close() @@ -66,6 +100,13 @@ class Tests { assertThat(animals.size).isEqualTo(2) assertThat(animals).contains("Neville Furbottom") assertThat(animals).contains("Edgar Allan Paw") + val quiteFluffyAnimals = queryFactory + .selectFrom(q) + .where(q.fluffiness.eq("Quite Fluffy")) + .fetch() + .map { it.name } + assertThat(quiteFluffyAnimals.size).isEqualTo(1) + assertThat(quiteFluffyAnimals).contains("Neville Furbottom") em.close() } } diff --git a/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt b/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt index 1d6443283f..3d7fdab3e8 100644 --- a/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt +++ b/querydsl-tooling/querydsl-ksp-codegen/src/main/kotlin/com/querydsl/ksp/codegen/TypeExtractor.kt @@ -45,7 +45,7 @@ class TypeExtractor( } private fun simpleType(type: KSType): QPropertyType.Simple? { - val className = type.toClassName() + val className = type.toClassNameSimple() val simpleType = SimpleType.Mapper.get(className) if (simpleType == null) { return null @@ -61,7 +61,7 @@ class TypeExtractor( if (declaration is KSClassDeclaration) { types.addAll(declaration.getAllSuperTypes()) } - val classNames = types.map { it.toClassName() } + val classNames = types.map { it.toClassNameSimple() } return if (classNames.any { it.isMap() }) { assertTypeArgCount(type, "map", 2) val keyType = extract(type.arguments[0].type!!.resolve()) @@ -86,7 +86,7 @@ class TypeExtractor( val referencedDeclaration = type.declaration if (referencedDeclaration is KSClassDeclaration) { return when (referencedDeclaration.classKind) { - ClassKind.ENUM_CLASS -> QPropertyType.EnumReference(type.toClassName()) + ClassKind.ENUM_CLASS -> QPropertyType.EnumReference(type.toClassNameSimple()) ClassKind.CLASS, ClassKind.INTERFACE -> { if (isEntity(referencedDeclaration)) { return QPropertyType.ObjectReference( @@ -115,7 +115,7 @@ class TypeExtractor( Convert::class.asClassName() ) if (property.annotations.any { userTypeAnnotations.contains(it.annotationType.resolve().toClassName()) }) { - return QPropertyType.Unknown(type.toClassName(), type.toTypeName()) + return QPropertyType.Unknown(type.toClassNameSimple(), type.toTypeName()) } else { return null } @@ -156,3 +156,15 @@ private fun ClassName.isList(): Boolean { private fun ClassName.isArray(): Boolean { return this == Array::class.asClassName() } + +/** + * Ignores arguments and nullability, returning simple ClassName. + */ +private fun KSType.toClassNameSimple(): ClassName { + return when (val decl = declaration) { + is KSClassDeclaration -> decl.toClassName() + is KSTypeAlias -> decl.toClassName() + is KSTypeParameter -> error("Cannot convert KSTypeParameter to ClassName: '$this'") + else -> error("Could not compute ClassName for '$this'") + } +} From 67ee529ecf35984c478ab6d6067c999c55da59da Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 13 Dec 2024 16:29:22 -0300 Subject: [PATCH 6/7] prepare release 6.10 --- pom.xml | 2 +- querydsl-docs/pom.xml | 2 +- querydsl-examples/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-quarkus/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-spring/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-jpa/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml | 2 +- querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-spring/pom.xml | 2 +- querydsl-libraries/pom.xml | 2 +- querydsl-libraries/querydsl-collections/pom.xml | 2 +- querydsl-libraries/querydsl-core/pom.xml | 2 +- querydsl-libraries/querydsl-guava/pom.xml | 2 +- querydsl-libraries/querydsl-jpa-spring/pom.xml | 2 +- querydsl-libraries/querydsl-jpa/pom.xml | 2 +- querydsl-libraries/querydsl-kotlin/pom.xml | 2 +- querydsl-libraries/querydsl-mongodb/pom.xml | 2 +- querydsl-libraries/querydsl-r2dbc/pom.xml | 2 +- querydsl-libraries/querydsl-scala/pom.xml | 2 +- querydsl-libraries/querydsl-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-json/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spring/pom.xml | 2 +- querydsl-libraries/querydsl-sql/pom.xml | 2 +- querydsl-tooling/pom.xml | 2 +- querydsl-tooling/querydsl-apt/pom.xml | 2 +- querydsl-tooling/querydsl-codegen-utils/pom.xml | 2 +- querydsl-tooling/querydsl-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-jpa-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-kotlin-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-ksp-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-maven-plugin/pom.xml | 2 +- querydsl-tooling/querydsl-sql-codegen/pom.xml | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index 15d4fca1f5..6a1af3446a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.openfeign.querydsl querydsl-root - 6.10-SNAPSHOT + 6.10 pom Querydsl diff --git a/querydsl-docs/pom.xml b/querydsl-docs/pom.xml index 3065816865..79ac5cc66e 100644 --- a/querydsl-docs/pom.xml +++ b/querydsl-docs/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10-SNAPSHOT + 6.10 querydsl-docs diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index ca90157eda..66a6085907 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10-SNAPSHOT + 6.10 querydsl-examples diff --git a/querydsl-examples/querydsl-example-jpa-guice/pom.xml b/querydsl-examples/querydsl-example-jpa-guice/pom.xml index 4e6c46a6ee..b3a2916bd6 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-jpa-guice diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml index e24fdd9db4..f555554b64 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-jpa-quarkus diff --git a/querydsl-examples/querydsl-example-jpa-spring/pom.xml b/querydsl-examples/querydsl-example-jpa-spring/pom.xml index 277fbfb68e..c989fd4b19 100755 --- a/querydsl-examples/querydsl-example-jpa-spring/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-spring/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-jpa-spring diff --git a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml index 2cb99487ed..67099025bf 100644 --- a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-kotlin-codegen Querydsl example - Kotlin Codegen diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml index 25965a44a7..881ef6bfdb 100644 --- a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-kotlin Querydsl example - Kotlin JPA diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml index 70aa93a36c..fdbea22081 100644 --- a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-kotlin-mongodb Querydsl example - Kotlin MongoDB diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml index 81d64b3780..71623eeae0 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-r2dbc-sql-codegen diff --git a/querydsl-examples/querydsl-example-sql-guice/pom.xml b/querydsl-examples/querydsl-example-sql-guice/pom.xml index 1e06d425b3..87b25de365 100644 --- a/querydsl-examples/querydsl-example-sql-guice/pom.xml +++ b/querydsl-examples/querydsl-example-sql-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-sql-guice diff --git a/querydsl-examples/querydsl-example-sql-spring/pom.xml b/querydsl-examples/querydsl-example-sql-spring/pom.xml index 622ae6a498..104cc6ebd6 100644 --- a/querydsl-examples/querydsl-example-sql-spring/pom.xml +++ b/querydsl-examples/querydsl-example-sql-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10-SNAPSHOT + 6.10 querydsl-example-sql-spring diff --git a/querydsl-libraries/pom.xml b/querydsl-libraries/pom.xml index 0282e9825f..7dc150c5e2 100644 --- a/querydsl-libraries/pom.xml +++ b/querydsl-libraries/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10-SNAPSHOT + 6.10 querydsl-libraries diff --git a/querydsl-libraries/querydsl-collections/pom.xml b/querydsl-libraries/querydsl-collections/pom.xml index bc77f77a84..12ee49fd32 100644 --- a/querydsl-libraries/querydsl-collections/pom.xml +++ b/querydsl-libraries/querydsl-collections/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 io.github.openfeign.querydsl diff --git a/querydsl-libraries/querydsl-core/pom.xml b/querydsl-libraries/querydsl-core/pom.xml index c6d3e79e47..ce2fd6b548 100644 --- a/querydsl-libraries/querydsl-core/pom.xml +++ b/querydsl-libraries/querydsl-core/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-core diff --git a/querydsl-libraries/querydsl-guava/pom.xml b/querydsl-libraries/querydsl-guava/pom.xml index e9f933970c..e01bb81923 100644 --- a/querydsl-libraries/querydsl-guava/pom.xml +++ b/querydsl-libraries/querydsl-guava/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-guava diff --git a/querydsl-libraries/querydsl-jpa-spring/pom.xml b/querydsl-libraries/querydsl-jpa-spring/pom.xml index 569b6fdbc1..03762790e2 100644 --- a/querydsl-libraries/querydsl-jpa-spring/pom.xml +++ b/querydsl-libraries/querydsl-jpa-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-jpa-spring diff --git a/querydsl-libraries/querydsl-jpa/pom.xml b/querydsl-libraries/querydsl-jpa/pom.xml index b6d83ef892..09919d3edd 100644 --- a/querydsl-libraries/querydsl-jpa/pom.xml +++ b/querydsl-libraries/querydsl-jpa/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-jpa diff --git a/querydsl-libraries/querydsl-kotlin/pom.xml b/querydsl-libraries/querydsl-kotlin/pom.xml index 76cd1c907b..e4cae8c4bb 100644 --- a/querydsl-libraries/querydsl-kotlin/pom.xml +++ b/querydsl-libraries/querydsl-kotlin/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-kotlin diff --git a/querydsl-libraries/querydsl-mongodb/pom.xml b/querydsl-libraries/querydsl-mongodb/pom.xml index 93101f0a09..ca71b5e90e 100644 --- a/querydsl-libraries/querydsl-mongodb/pom.xml +++ b/querydsl-libraries/querydsl-mongodb/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-mongodb diff --git a/querydsl-libraries/querydsl-r2dbc/pom.xml b/querydsl-libraries/querydsl-r2dbc/pom.xml index 8825bc8241..23faf9fab5 100644 --- a/querydsl-libraries/querydsl-r2dbc/pom.xml +++ b/querydsl-libraries/querydsl-r2dbc/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-r2dbc diff --git a/querydsl-libraries/querydsl-scala/pom.xml b/querydsl-libraries/querydsl-scala/pom.xml index aba929f86a..5662be3b10 100644 --- a/querydsl-libraries/querydsl-scala/pom.xml +++ b/querydsl-libraries/querydsl-scala/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-scala diff --git a/querydsl-libraries/querydsl-spatial/pom.xml b/querydsl-libraries/querydsl-spatial/pom.xml index d0797de738..b82792438a 100644 --- a/querydsl-libraries/querydsl-spatial/pom.xml +++ b/querydsl-libraries/querydsl-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-spatial diff --git a/querydsl-libraries/querydsl-sql-json/pom.xml b/querydsl-libraries/querydsl-sql-json/pom.xml index ea59746713..81904d54b2 100644 --- a/querydsl-libraries/querydsl-sql-json/pom.xml +++ b/querydsl-libraries/querydsl-sql-json/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-sql-json diff --git a/querydsl-libraries/querydsl-sql-spatial/pom.xml b/querydsl-libraries/querydsl-sql-spatial/pom.xml index e7d1a63951..772ca05106 100644 --- a/querydsl-libraries/querydsl-sql-spatial/pom.xml +++ b/querydsl-libraries/querydsl-sql-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-sql-spatial diff --git a/querydsl-libraries/querydsl-sql-spring/pom.xml b/querydsl-libraries/querydsl-sql-spring/pom.xml index 3751a693ed..ddb4c2fab6 100644 --- a/querydsl-libraries/querydsl-sql-spring/pom.xml +++ b/querydsl-libraries/querydsl-sql-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-sql-spring diff --git a/querydsl-libraries/querydsl-sql/pom.xml b/querydsl-libraries/querydsl-sql/pom.xml index bc1c36ab6f..f9b13972f3 100644 --- a/querydsl-libraries/querydsl-sql/pom.xml +++ b/querydsl-libraries/querydsl-sql/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10-SNAPSHOT + 6.10 querydsl-sql diff --git a/querydsl-tooling/pom.xml b/querydsl-tooling/pom.xml index 3bf91b122c..da3d9213be 100644 --- a/querydsl-tooling/pom.xml +++ b/querydsl-tooling/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10-SNAPSHOT + 6.10 querydsl-tooling diff --git a/querydsl-tooling/querydsl-apt/pom.xml b/querydsl-tooling/querydsl-apt/pom.xml index 6d3ca279d9..7c7a470c21 100644 --- a/querydsl-tooling/querydsl-apt/pom.xml +++ b/querydsl-tooling/querydsl-apt/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-apt diff --git a/querydsl-tooling/querydsl-codegen-utils/pom.xml b/querydsl-tooling/querydsl-codegen-utils/pom.xml index 36a7a8d3f7..89669e1ac6 100644 --- a/querydsl-tooling/querydsl-codegen-utils/pom.xml +++ b/querydsl-tooling/querydsl-codegen-utils/pom.xml @@ -6,7 +6,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-codegen-utils diff --git a/querydsl-tooling/querydsl-codegen/pom.xml b/querydsl-tooling/querydsl-codegen/pom.xml index 5fbc30a1f3..6ce64d39fa 100644 --- a/querydsl-tooling/querydsl-codegen/pom.xml +++ b/querydsl-tooling/querydsl-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-codegen diff --git a/querydsl-tooling/querydsl-jpa-codegen/pom.xml b/querydsl-tooling/querydsl-jpa-codegen/pom.xml index d7039ee406..d47ef93229 100644 --- a/querydsl-tooling/querydsl-jpa-codegen/pom.xml +++ b/querydsl-tooling/querydsl-jpa-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-jpa-codegen diff --git a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml index 5be50f266d..d4d133f193 100644 --- a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml +++ b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-kotlin-codegen diff --git a/querydsl-tooling/querydsl-ksp-codegen/pom.xml b/querydsl-tooling/querydsl-ksp-codegen/pom.xml index e7b973068f..f2520eee09 100644 --- a/querydsl-tooling/querydsl-ksp-codegen/pom.xml +++ b/querydsl-tooling/querydsl-ksp-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-ksp-codegen diff --git a/querydsl-tooling/querydsl-maven-plugin/pom.xml b/querydsl-tooling/querydsl-maven-plugin/pom.xml index 9abce25d04..39a9347add 100644 --- a/querydsl-tooling/querydsl-maven-plugin/pom.xml +++ b/querydsl-tooling/querydsl-maven-plugin/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-maven-plugin diff --git a/querydsl-tooling/querydsl-sql-codegen/pom.xml b/querydsl-tooling/querydsl-sql-codegen/pom.xml index 063a8b32ab..ea92102973 100644 --- a/querydsl-tooling/querydsl-sql-codegen/pom.xml +++ b/querydsl-tooling/querydsl-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10-SNAPSHOT + 6.10 querydsl-sql-codegen From 423b275444d7842e91235d286a589ec480446f50 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 13 Dec 2024 16:29:32 -0300 Subject: [PATCH 7/7] [ci skip] updating versions to next development iteration 6.11-SNAPSHOT --- pom.xml | 2 +- querydsl-docs/pom.xml | 2 +- querydsl-examples/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-quarkus/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-spring/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-jpa/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml | 2 +- querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-spring/pom.xml | 2 +- querydsl-libraries/pom.xml | 2 +- querydsl-libraries/querydsl-collections/pom.xml | 2 +- querydsl-libraries/querydsl-core/pom.xml | 2 +- querydsl-libraries/querydsl-guava/pom.xml | 2 +- querydsl-libraries/querydsl-jpa-spring/pom.xml | 2 +- querydsl-libraries/querydsl-jpa/pom.xml | 2 +- querydsl-libraries/querydsl-kotlin/pom.xml | 2 +- querydsl-libraries/querydsl-mongodb/pom.xml | 2 +- querydsl-libraries/querydsl-r2dbc/pom.xml | 2 +- querydsl-libraries/querydsl-scala/pom.xml | 2 +- querydsl-libraries/querydsl-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-json/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spring/pom.xml | 2 +- querydsl-libraries/querydsl-sql/pom.xml | 2 +- querydsl-tooling/pom.xml | 2 +- querydsl-tooling/querydsl-apt/pom.xml | 2 +- querydsl-tooling/querydsl-codegen-utils/pom.xml | 2 +- querydsl-tooling/querydsl-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-jpa-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-kotlin-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-ksp-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-maven-plugin/pom.xml | 2 +- querydsl-tooling/querydsl-sql-codegen/pom.xml | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index 6a1af3446a..302c581fd5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.openfeign.querydsl querydsl-root - 6.10 + 6.11-SNAPSHOT pom Querydsl diff --git a/querydsl-docs/pom.xml b/querydsl-docs/pom.xml index 79ac5cc66e..7d9bce5706 100644 --- a/querydsl-docs/pom.xml +++ b/querydsl-docs/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10 + 6.11-SNAPSHOT querydsl-docs diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index 66a6085907..fe039eb374 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10 + 6.11-SNAPSHOT querydsl-examples diff --git a/querydsl-examples/querydsl-example-jpa-guice/pom.xml b/querydsl-examples/querydsl-example-jpa-guice/pom.xml index b3a2916bd6..b9a0bffa28 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-jpa-guice diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml index f555554b64..847819dff2 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-jpa-quarkus diff --git a/querydsl-examples/querydsl-example-jpa-spring/pom.xml b/querydsl-examples/querydsl-example-jpa-spring/pom.xml index c989fd4b19..d11843b154 100755 --- a/querydsl-examples/querydsl-example-jpa-spring/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-spring/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-jpa-spring diff --git a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml index 67099025bf..0fe87b2583 100644 --- a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-kotlin-codegen Querydsl example - Kotlin Codegen diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml index 881ef6bfdb..5ceef575df 100644 --- a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-kotlin Querydsl example - Kotlin JPA diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml index fdbea22081..bb2763ffa5 100644 --- a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-kotlin-mongodb Querydsl example - Kotlin MongoDB diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml index 71623eeae0..ab979aad4b 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-r2dbc-sql-codegen diff --git a/querydsl-examples/querydsl-example-sql-guice/pom.xml b/querydsl-examples/querydsl-example-sql-guice/pom.xml index 87b25de365..1956453719 100644 --- a/querydsl-examples/querydsl-example-sql-guice/pom.xml +++ b/querydsl-examples/querydsl-example-sql-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-sql-guice diff --git a/querydsl-examples/querydsl-example-sql-spring/pom.xml b/querydsl-examples/querydsl-example-sql-spring/pom.xml index 104cc6ebd6..971a10c7be 100644 --- a/querydsl-examples/querydsl-example-sql-spring/pom.xml +++ b/querydsl-examples/querydsl-example-sql-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.10 + 6.11-SNAPSHOT querydsl-example-sql-spring diff --git a/querydsl-libraries/pom.xml b/querydsl-libraries/pom.xml index 7dc150c5e2..71279261b3 100644 --- a/querydsl-libraries/pom.xml +++ b/querydsl-libraries/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10 + 6.11-SNAPSHOT querydsl-libraries diff --git a/querydsl-libraries/querydsl-collections/pom.xml b/querydsl-libraries/querydsl-collections/pom.xml index 12ee49fd32..268473a342 100644 --- a/querydsl-libraries/querydsl-collections/pom.xml +++ b/querydsl-libraries/querydsl-collections/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT io.github.openfeign.querydsl diff --git a/querydsl-libraries/querydsl-core/pom.xml b/querydsl-libraries/querydsl-core/pom.xml index ce2fd6b548..b9cc4e6c5d 100644 --- a/querydsl-libraries/querydsl-core/pom.xml +++ b/querydsl-libraries/querydsl-core/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-core diff --git a/querydsl-libraries/querydsl-guava/pom.xml b/querydsl-libraries/querydsl-guava/pom.xml index e01bb81923..3f0e299d95 100644 --- a/querydsl-libraries/querydsl-guava/pom.xml +++ b/querydsl-libraries/querydsl-guava/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-guava diff --git a/querydsl-libraries/querydsl-jpa-spring/pom.xml b/querydsl-libraries/querydsl-jpa-spring/pom.xml index 03762790e2..5ab92be55e 100644 --- a/querydsl-libraries/querydsl-jpa-spring/pom.xml +++ b/querydsl-libraries/querydsl-jpa-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-jpa-spring diff --git a/querydsl-libraries/querydsl-jpa/pom.xml b/querydsl-libraries/querydsl-jpa/pom.xml index 09919d3edd..acbf87aa0d 100644 --- a/querydsl-libraries/querydsl-jpa/pom.xml +++ b/querydsl-libraries/querydsl-jpa/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-jpa diff --git a/querydsl-libraries/querydsl-kotlin/pom.xml b/querydsl-libraries/querydsl-kotlin/pom.xml index e4cae8c4bb..b473f3325a 100644 --- a/querydsl-libraries/querydsl-kotlin/pom.xml +++ b/querydsl-libraries/querydsl-kotlin/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-kotlin diff --git a/querydsl-libraries/querydsl-mongodb/pom.xml b/querydsl-libraries/querydsl-mongodb/pom.xml index ca71b5e90e..b97bc372fe 100644 --- a/querydsl-libraries/querydsl-mongodb/pom.xml +++ b/querydsl-libraries/querydsl-mongodb/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-mongodb diff --git a/querydsl-libraries/querydsl-r2dbc/pom.xml b/querydsl-libraries/querydsl-r2dbc/pom.xml index 23faf9fab5..4c84544f2e 100644 --- a/querydsl-libraries/querydsl-r2dbc/pom.xml +++ b/querydsl-libraries/querydsl-r2dbc/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-r2dbc diff --git a/querydsl-libraries/querydsl-scala/pom.xml b/querydsl-libraries/querydsl-scala/pom.xml index 5662be3b10..c5e1a1c8ea 100644 --- a/querydsl-libraries/querydsl-scala/pom.xml +++ b/querydsl-libraries/querydsl-scala/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-scala diff --git a/querydsl-libraries/querydsl-spatial/pom.xml b/querydsl-libraries/querydsl-spatial/pom.xml index b82792438a..49938b2d72 100644 --- a/querydsl-libraries/querydsl-spatial/pom.xml +++ b/querydsl-libraries/querydsl-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-spatial diff --git a/querydsl-libraries/querydsl-sql-json/pom.xml b/querydsl-libraries/querydsl-sql-json/pom.xml index 81904d54b2..d8f0f97fe0 100644 --- a/querydsl-libraries/querydsl-sql-json/pom.xml +++ b/querydsl-libraries/querydsl-sql-json/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-sql-json diff --git a/querydsl-libraries/querydsl-sql-spatial/pom.xml b/querydsl-libraries/querydsl-sql-spatial/pom.xml index 772ca05106..9ed1b11deb 100644 --- a/querydsl-libraries/querydsl-sql-spatial/pom.xml +++ b/querydsl-libraries/querydsl-sql-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-sql-spatial diff --git a/querydsl-libraries/querydsl-sql-spring/pom.xml b/querydsl-libraries/querydsl-sql-spring/pom.xml index ddb4c2fab6..688b7a5d1d 100644 --- a/querydsl-libraries/querydsl-sql-spring/pom.xml +++ b/querydsl-libraries/querydsl-sql-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-sql-spring diff --git a/querydsl-libraries/querydsl-sql/pom.xml b/querydsl-libraries/querydsl-sql/pom.xml index f9b13972f3..1f51e76c92 100644 --- a/querydsl-libraries/querydsl-sql/pom.xml +++ b/querydsl-libraries/querydsl-sql/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.10 + 6.11-SNAPSHOT querydsl-sql diff --git a/querydsl-tooling/pom.xml b/querydsl-tooling/pom.xml index da3d9213be..23e1fdfcbc 100644 --- a/querydsl-tooling/pom.xml +++ b/querydsl-tooling/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.10 + 6.11-SNAPSHOT querydsl-tooling diff --git a/querydsl-tooling/querydsl-apt/pom.xml b/querydsl-tooling/querydsl-apt/pom.xml index 7c7a470c21..f5003452ff 100644 --- a/querydsl-tooling/querydsl-apt/pom.xml +++ b/querydsl-tooling/querydsl-apt/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-apt diff --git a/querydsl-tooling/querydsl-codegen-utils/pom.xml b/querydsl-tooling/querydsl-codegen-utils/pom.xml index 89669e1ac6..a59cf4ffac 100644 --- a/querydsl-tooling/querydsl-codegen-utils/pom.xml +++ b/querydsl-tooling/querydsl-codegen-utils/pom.xml @@ -6,7 +6,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-codegen-utils diff --git a/querydsl-tooling/querydsl-codegen/pom.xml b/querydsl-tooling/querydsl-codegen/pom.xml index 6ce64d39fa..e07cc46536 100644 --- a/querydsl-tooling/querydsl-codegen/pom.xml +++ b/querydsl-tooling/querydsl-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-codegen diff --git a/querydsl-tooling/querydsl-jpa-codegen/pom.xml b/querydsl-tooling/querydsl-jpa-codegen/pom.xml index d47ef93229..9ef00b92d9 100644 --- a/querydsl-tooling/querydsl-jpa-codegen/pom.xml +++ b/querydsl-tooling/querydsl-jpa-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-jpa-codegen diff --git a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml index d4d133f193..04eb96bb13 100644 --- a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml +++ b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-kotlin-codegen diff --git a/querydsl-tooling/querydsl-ksp-codegen/pom.xml b/querydsl-tooling/querydsl-ksp-codegen/pom.xml index f2520eee09..0f244dcb6b 100644 --- a/querydsl-tooling/querydsl-ksp-codegen/pom.xml +++ b/querydsl-tooling/querydsl-ksp-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-ksp-codegen diff --git a/querydsl-tooling/querydsl-maven-plugin/pom.xml b/querydsl-tooling/querydsl-maven-plugin/pom.xml index 39a9347add..f377f307f6 100644 --- a/querydsl-tooling/querydsl-maven-plugin/pom.xml +++ b/querydsl-tooling/querydsl-maven-plugin/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-maven-plugin diff --git a/querydsl-tooling/querydsl-sql-codegen/pom.xml b/querydsl-tooling/querydsl-sql-codegen/pom.xml index ea92102973..6d23508ed3 100644 --- a/querydsl-tooling/querydsl-sql-codegen/pom.xml +++ b/querydsl-tooling/querydsl-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.10 + 6.11-SNAPSHOT querydsl-sql-codegen