diff --git a/mmm-util-query/README.md b/mmm-util-query/README.md new file mode 100644 index 000000000..98cf891a0 --- /dev/null +++ b/mmm-util-query/README.md @@ -0,0 +1,12 @@ +# Mature Modular Meta-framework (mmm) + +![logo](https://raw.github.com/m-m-m/mmm/master/src/site/resources/images/logo.png) + +**Welcome to the wonderful world of [mmm](http://m-m-m.sourceforge.net/index.html)!** + +## mmm-util-property + +This module is part of the [mmm-util project](../README.md) and brings extended property and bean support including +* [Properties](http://m-m-m.github.io/maven/apidocs/net/sf/mmm/util/property/api/package-summary.html#package.description) extending JavaFx properties with type reflection and validation support. +* [Bean](http://m-m-m.github.io/maven/apidocs/net/sf/mmm/util/bean/api/package-summary.html#package.description) to implement beans as interface without writing any boiler-plate code. +* and much more... diff --git a/mmm-util-query/pom.xml b/mmm-util-query/pom.xml new file mode 100644 index 000000000..e0c31d851 --- /dev/null +++ b/mmm-util-query/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + net.sf.m-m-m + mmm-util-modules + dev-SNAPSHOT + ../mmm-util-modules/pom.xml + + mmm-util-query + ${net.sf.mmm.util.version} + jar + ${project.artifactId} + This project allows to build queries with a fluent and type-safe API. + + + + ${project.groupId} + mmm-util-property + ${net.sf.mmm.util.version} + + + ${project.groupId} + mmm-util-test + test + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + true + + + org.hibernate + hibernate-entitymanager + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/DeleteStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/DeleteStatement.java similarity index 77% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/DeleteStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/DeleteStatement.java index a2aa1ed45..7716cb8b5 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/DeleteStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/DeleteStatement.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; -import net.sf.mmm.util.property.api.query.feature.FeatureLimit; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.FeatureLimit; +import net.sf.mmm.util.query.api.feature.FeatureWhere; /** * Extends {@link Statement} for {@code UPDATE} statements. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/InsertStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/InsertStatement.java similarity index 92% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/InsertStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/InsertStatement.java index abf7cc7db..55e6469a3 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/InsertStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/InsertStatement.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; /** * Extends {@link Statement} for {@code INSERT} statements. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/ModifyStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/ModifyStatement.java similarity index 85% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/ModifyStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/ModifyStatement.java index a5d521d83..a49187a79 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/ModifyStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/ModifyStatement.java @@ -1,8 +1,8 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; -import net.sf.mmm.util.property.api.query.feature.FeatureModify; +import net.sf.mmm.util.query.api.feature.FeatureModify; /** * Extends {@link Statement} for modifying data. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/SelectStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/SelectStatement.java similarity index 67% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/SelectStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/SelectStatement.java index 4f0950f4d..f01b2edbb 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/SelectStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/SelectStatement.java @@ -1,12 +1,12 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; -import net.sf.mmm.util.property.api.query.feature.FeatureFetch; -import net.sf.mmm.util.property.api.query.feature.FeatureGroupBy; -import net.sf.mmm.util.property.api.query.feature.FeatureOrderBy; -import net.sf.mmm.util.property.api.query.feature.FeaturePaging; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.FeatureFetch; +import net.sf.mmm.util.query.api.feature.FeatureGroupBy; +import net.sf.mmm.util.query.api.feature.FeatureOrderBy; +import net.sf.mmm.util.query.api.feature.FeaturePaging; +import net.sf.mmm.util.query.api.feature.FeatureWhere; /** * Extends {@link Statement} for regular {@code SELECT} statements to retrieve results (unlike {@link InsertStatement diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/Statement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/Statement.java similarity index 93% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/Statement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/Statement.java index a6b55652b..275b7ab1f 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/Statement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/Statement.java @@ -1,12 +1,12 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; import java.util.List; import net.sf.mmm.util.property.api.expression.Expression; import net.sf.mmm.util.property.api.path.PropertyPath; -import net.sf.mmm.util.property.base.query.SqlDialect; +import net.sf.mmm.util.query.base.SqlDialect; /** * This interface allows to build and execute type-safe query statements using a fluent API based on diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/StoreStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/StoreStatement.java similarity index 85% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/StoreStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/StoreStatement.java index f4606ce71..d79671959 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/StoreStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/StoreStatement.java @@ -1,8 +1,8 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; -import net.sf.mmm.util.property.api.query.feature.FeatureSet; +import net.sf.mmm.util.query.api.feature.FeatureSet; /** * Extends {@link Statement} for storing data. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/UpdateStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/UpdateStatement.java similarity index 77% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/UpdateStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/UpdateStatement.java index 4b9b42fd7..9ad459470 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/UpdateStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/UpdateStatement.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api; -import net.sf.mmm.util.property.api.query.feature.FeatureLimit; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.FeatureLimit; +import net.sf.mmm.util.query.api.feature.FeatureWhere; /** * Extends {@link Statement} for {@code UPDATE} statements. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureFetch.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureFetch.java similarity index 87% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureFetch.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureFetch.java index cbef30640..461c1c728 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureFetch.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureFetch.java @@ -1,14 +1,14 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import java.util.List; /** - * A {@link FeatureFetch} is for a regular query {@link net.sf.mmm.util.property.api.query.Statement} to fetch and + * A {@link FeatureFetch} is for a regular query {@link net.sf.mmm.util.query.api.Statement} to fetch and * retrieve results. * - * @see net.sf.mmm.util.property.api.query.SelectStatement + * @see net.sf.mmm.util.query.api.SelectStatement * * @param the generic type of the entity to fetch. * diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureGroupBy.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureGroupBy.java similarity index 88% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureGroupBy.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureGroupBy.java index 28b38455b..fbdccaa22 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureGroupBy.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureGroupBy.java @@ -1,11 +1,11 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import net.sf.mmm.util.property.api.path.PropertyPath; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} allowing a + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing a * {@link #groupBy(PropertyPath) GROUP BY clause}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureHaving.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureHaving.java similarity index 90% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureHaving.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureHaving.java index 92ab6af9f..687136218 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureHaving.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureHaving.java @@ -1,11 +1,11 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import net.sf.mmm.util.property.api.expression.Expression; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} allowing a + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing a * {@link #having(Expression...) HAVING clause}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureLimit.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureLimit.java similarity index 87% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureLimit.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureLimit.java index 2a30449d7..b3bc04561 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureLimit.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureLimit.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} with support for + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} with support for * {@link #limit(long)}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureModify.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureModify.java similarity index 67% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureModify.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureModify.java index 498bb1d92..68ea84056 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureModify.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureModify.java @@ -1,13 +1,13 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; -import net.sf.mmm.util.property.api.query.Statement; +import net.sf.mmm.util.query.api.Statement; /** - * Extends {@link Statement} for a query {@link net.sf.mmm.util.property.api.query.Statement} that modifies data. + * Extends {@link Statement} for a query {@link net.sf.mmm.util.query.api.Statement} that modifies data. * - * @see net.sf.mmm.util.property.api.query.ModifyStatement + * @see net.sf.mmm.util.query.api.ModifyStatement * * @author hohwille * @since 8.0.0 diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureOrderBy.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureOrderBy.java similarity index 92% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureOrderBy.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureOrderBy.java index 18df8cfd2..aa5c7533a 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureOrderBy.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureOrderBy.java @@ -1,12 +1,12 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import net.sf.mmm.util.lang.api.SortOrder; import net.sf.mmm.util.property.api.path.PropertyPath; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} allowing an + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing an * {@link #orderBy(PropertyPath, SortOrder) ORDER BY clause}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeaturePaging.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeaturePaging.java similarity index 88% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeaturePaging.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeaturePaging.java index 957574309..8b3db6e74 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeaturePaging.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeaturePaging.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} with paging support + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} with paging support * via {@link #limit(long)} and {@link #offset(long)}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureSet.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureSet.java similarity index 94% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureSet.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureSet.java index 230abb39f..b09cd452a 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureSet.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureSet.java @@ -1,11 +1,11 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import net.sf.mmm.util.property.api.path.PropertyPath; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} allowing a + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing a * {@link #set(PropertyPath, Object) SET clause}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureValues.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureValues.java new file mode 100644 index 000000000..6b96162cf --- /dev/null +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureValues.java @@ -0,0 +1,34 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.query.api.feature; + +import net.sf.mmm.util.property.api.path.PropertyPath; + +/** + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing a + * {@link #value(PropertyPath, Object) VALUES clause}. For each invocation of {@link #value(PropertyPath, Object) + * value(pI, vI)} a value binding is added so in the end the resulting SQL fragment will be: + * + *
+ * (p1, p2, ..., pN) VALUES (v1, v2, ..., vN)
+ * 
+ * + * @param the generic type of this query itself (this) for fluent API calls. + * + * @author hohwille + * @since 8.0.0 + */ +public abstract interface FeatureValues> extends StatementFeature { + + /** + * Adds a value binding setting the given {@link PropertyPath} to the given {@code value}. + * + * @param the generic type of the {@code value}. + * @param path the {@link PropertyPath} for the value to assign that will be added to the bracket before the + * {@ocde VALUES} keyword. + * @param value the literal value to assign that will be added to the bracket after the {@ocde VALUES} keyword. + * @return this query instance for fluent API calls. + */ + SELF value(PropertyPath path, V value); + +} diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureWhere.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureWhere.java similarity index 90% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureWhere.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureWhere.java index 00eb52bb6..ae4a4871f 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/FeatureWhere.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/FeatureWhere.java @@ -1,11 +1,11 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; import net.sf.mmm.util.property.api.expression.Expression; /** - * This is the abstract interface for a query {@link net.sf.mmm.util.property.api.query.Statement} allowing a + * This is the abstract interface for a query {@link net.sf.mmm.util.query.api.Statement} allowing a * {@link #where(Expression...) WHERE clause}. * * @param the generic type of this query itself (this) for fluent API calls. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/StatementFeature.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/StatementFeature.java similarity index 60% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/StatementFeature.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/StatementFeature.java index 2059be75f..ea9835792 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/feature/StatementFeature.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/feature/StatementFeature.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query.feature; +package net.sf.mmm.util.query.api.feature; /** - * Marker interface for a feature on a {@link net.sf.mmm.util.property.api.query.Statement}. + * Marker interface for a feature on a {@link net.sf.mmm.util.query.api.Statement}. * * @author hohwille * @since 8.0.0 diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/JpqlSelectStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/jpql/JpqlSelectStatement.java similarity index 57% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/JpqlSelectStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/api/jpql/JpqlSelectStatement.java index 42c6998e0..d4fdcbeed 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/api/query/JpqlSelectStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/jpql/JpqlSelectStatement.java @@ -1,20 +1,20 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.api.query; +package net.sf.mmm.util.query.api.jpql; -import net.sf.mmm.util.property.api.query.feature.FeatureHaving; +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureHaving; /** * Extends a regular {@link SelectStatement} with advanced features like * {@link #having(net.sf.mmm.util.property.api.expression.Expression...) HAVING clause}. * * @param the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}). - * @param the generic type of this query itself (this) for fluent API calls. * * @author hohwille * @since 8.0.0 */ -public interface JpqlSelectStatement> - extends SelectStatement, FeatureHaving { +public interface JpqlSelectStatement + extends SelectStatement>, FeatureHaving> { } diff --git a/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/orientdb/OrientDbSelectStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/orientdb/OrientDbSelectStatement.java new file mode 100644 index 000000000..73c67179e --- /dev/null +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/api/orientdb/OrientDbSelectStatement.java @@ -0,0 +1,20 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.query.api.orientdb; + +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureHaving; + +/** + * Extends a regular {@link SelectStatement} with advanced features like + * {@link #having(net.sf.mmm.util.property.api.expression.Expression...) HAVING clause}. + * + * @param the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}). + * + * @author hohwille + * @since 8.0.0 + */ +public interface OrientDbSelectStatement + extends SelectStatement>, FeatureHaving> { + +} diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractDeleteStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractDeleteStatement.java similarity index 91% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractDeleteStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractDeleteStatement.java index 455f6db05..2021bd718 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractDeleteStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractDeleteStatement.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import net.sf.mmm.util.property.api.expression.Expression; -import net.sf.mmm.util.property.api.query.DeleteStatement; +import net.sf.mmm.util.query.api.DeleteStatement; /** * This is the abstract base-implementation of {@link DeleteStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractInsertStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractInsertStatement.java similarity index 89% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractInsertStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractInsertStatement.java index f500225f0..df5656800 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractInsertStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractInsertStatement.java @@ -1,8 +1,8 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; -import net.sf.mmm.util.property.api.query.InsertStatement; +import net.sf.mmm.util.query.api.InsertStatement; /** * This is the abstract base-implementation of {@link InsertStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractModifyStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractModifyStatement.java similarity index 88% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractModifyStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractModifyStatement.java index 24a03d0e3..9322e232e 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractModifyStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractModifyStatement.java @@ -1,8 +1,8 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; -import net.sf.mmm.util.property.api.query.ModifyStatement; +import net.sf.mmm.util.query.api.ModifyStatement; /** * This is the abstract base-implementation of {@link ModifyStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractSelectStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractSelectStatement.java similarity index 96% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractSelectStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractSelectStatement.java index b3cabec0e..8679b4b22 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractSelectStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractSelectStatement.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.ArrayList; import java.util.List; @@ -8,7 +8,7 @@ import net.sf.mmm.util.lang.api.SortOrder; import net.sf.mmm.util.property.api.expression.Expression; import net.sf.mmm.util.property.api.path.PropertyPath; -import net.sf.mmm.util.property.api.query.SelectStatement; +import net.sf.mmm.util.query.api.SelectStatement; /** * This is the abstract base-implementation of {@link SelectStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStatement.java similarity index 93% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStatement.java index 2276c2596..f11b9647d 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStatement.java @@ -1,13 +1,13 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.List; import net.sf.mmm.util.lang.api.Conjunction; import net.sf.mmm.util.property.api.expression.Expression; -import net.sf.mmm.util.property.api.query.Statement; import net.sf.mmm.util.property.base.expression.Expressions; +import net.sf.mmm.util.query.api.Statement; /** * This is the abstract base-implementation of {@link Statement}. @@ -64,7 +64,7 @@ protected SELF self() { } /** - * @see net.sf.mmm.util.property.api.query.feature.FeatureWhere#where(Expression...) + * @see net.sf.mmm.util.query.api.feature.FeatureWhere#where(Expression...) * @param expressions the {@link Expression}s to add. * @return this query instance for fluent API calls. */ @@ -79,7 +79,7 @@ protected SELF where(Expression... expressions) { } /** - * @see net.sf.mmm.util.property.api.query.feature.FeatureLimit#limit(long) + * @see net.sf.mmm.util.query.api.feature.FeatureLimit#limit(long) * @param newLimit the maximum number of matches. * @return this query instance for fluent API calls. */ @@ -90,7 +90,7 @@ protected SELF limit(long newLimit) { } /** - * @see net.sf.mmm.util.property.api.query.feature.FeaturePaging#offset(long) + * @see net.sf.mmm.util.query.api.feature.FeaturePaging#offset(long) * @param newOffset the number of records to skip. * @return this query instance for fluent API calls. */ diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStoreStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStoreStatement.java similarity index 96% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStoreStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStoreStatement.java index 9e11176c6..dd243103d 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractStoreStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractStoreStatement.java @@ -1,13 +1,13 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.ArrayList; import java.util.List; import net.sf.mmm.util.property.api.path.PropertyPath; -import net.sf.mmm.util.property.api.query.StoreStatement; import net.sf.mmm.util.property.base.expression.Arg; +import net.sf.mmm.util.query.api.StoreStatement; /** * This is the abstract base-implementation of {@link StoreStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractUpdateStatement.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractUpdateStatement.java similarity index 91% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractUpdateStatement.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractUpdateStatement.java index 7f6bc5025..19e4099f6 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/AbstractUpdateStatement.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/AbstractUpdateStatement.java @@ -1,9 +1,9 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import net.sf.mmm.util.property.api.expression.Expression; -import net.sf.mmm.util.property.api.query.UpdateStatement; +import net.sf.mmm.util.query.api.UpdateStatement; /** * This is the abstract base-implementation of {@link UpdateStatement}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/DefaultSqlDialect.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/DefaultSqlDialect.java similarity index 91% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/DefaultSqlDialect.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/DefaultSqlDialect.java index 04aad60d4..25bd78d1c 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/DefaultSqlDialect.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/DefaultSqlDialect.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; /** * The default implementation of {@link SqlDialect}. diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlBuilder.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlBuilder.java similarity index 97% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlBuilder.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlBuilder.java index 05757a646..1d4cfd972 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlBuilder.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlBuilder.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.ArrayList; import java.util.Arrays; @@ -15,8 +15,8 @@ import net.sf.mmm.util.property.base.expression.SingleExpression; import net.sf.mmm.util.property.base.expression.SqlOperator; import net.sf.mmm.util.property.base.expression.SqlOperator.SqlOperatorLike; -import net.sf.mmm.util.property.base.query.AbstractSelectStatement.OrderByExpression; -import net.sf.mmm.util.property.base.query.AbstractStoreStatement.SetExpression; +import net.sf.mmm.util.query.base.AbstractSelectStatement.OrderByExpression; +import net.sf.mmm.util.query.base.AbstractStoreStatement.SetExpression; import net.sf.mmm.util.value.api.Range; /** diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlDialect.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlDialect.java similarity index 99% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlDialect.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlDialect.java index 53ffa611f..4a6a0b4db 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/SqlDialect.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/SqlDialect.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import net.sf.mmm.util.lang.api.Conjunction; import net.sf.mmm.util.lang.api.SortOrder; diff --git a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/JpqlDialect.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/jpql/JpqlDialect.java similarity index 68% rename from mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/JpqlDialect.java rename to mmm-util-query/src/main/java/net/sf/mmm/util/query/base/jpql/JpqlDialect.java index f38c5fc1d..9b2d24ad3 100644 --- a/mmm-util-property/src/main/java/net/sf/mmm/util/property/base/query/JpqlDialect.java +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/jpql/JpqlDialect.java @@ -1,12 +1,16 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base.jpql; + +import net.sf.mmm.util.query.base.SqlDialect; /** - * The implementation of {@link SqlDialect} for JPQL. + * The implementation of {@link SqlDialect} for + * Java Persistence Query Language + * (JPQL). * * @author hohwille - * @since 7.1.0 + * @since 8.0.0 */ public class JpqlDialect extends Object implements SqlDialect { diff --git a/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/orientdb/OrientDbDialect.java b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/orientdb/OrientDbDialect.java new file mode 100644 index 000000000..01710ae90 --- /dev/null +++ b/mmm-util-query/src/main/java/net/sf/mmm/util/query/base/orientdb/OrientDbDialect.java @@ -0,0 +1,31 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.query.base.orientdb; + +import net.sf.mmm.util.query.base.SqlDialect; + +/** + * The implementation of {@link SqlDialect} for OrientDB. + * + * @author hohwille + * @since 8.0.0 + */ +public class OrientDbDialect extends Object implements SqlDialect { + + /** The singleton instance of this class. */ + public static final OrientDbDialect INSTANCE = new OrientDbDialect(); + + /** + * The constructor. + */ + public OrientDbDialect() { + super(); + } + + @Override + public String quoteReference() { + + return ""; + } + +} diff --git a/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/CountryCodeProperty.java b/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/CountryCodeProperty.java new file mode 100644 index 000000000..bdbdb535d --- /dev/null +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/CountryCodeProperty.java @@ -0,0 +1,47 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.bean.impl.example; + +import java.util.regex.Pattern; + +import net.sf.mmm.util.bean.api.Bean; +import net.sf.mmm.util.property.api.lang.StringProperty; +import net.sf.mmm.util.validation.base.AbstractValidator; +import net.sf.mmm.util.validation.base.ComposedValidator; +import net.sf.mmm.util.validation.base.ValidatorMandatory; +import net.sf.mmm.util.validation.base.text.ValidatorPattern; + +/** + * This is a {@link StringProperty} for a country code. + * + * @author hohwille + */ +public class CountryCodeProperty extends StringProperty { + + private static final Pattern PATTERN = Pattern.compile("[A-Z]{2}"); + + private static final AbstractValidator VALIDATOR = new ComposedValidator<>( + ValidatorMandatory.getInstance(), new ValidatorPattern(PATTERN)); + + /** + * The constructor. + * + * @param name - see {@link #getName()}. + * @param bean - see {@link #getBean()}. + */ + public CountryCodeProperty(String name, Bean bean) { + super(name, bean, VALIDATOR); + } + + /** + * The constructor. + * + * @param name - see {@link #getName()}. + * @param bean - see {@link #getBean()}. + * @param validator - see {@link #validate()}. + */ + protected CountryCodeProperty(String name, Bean bean, AbstractValidator validator) { + super(name, bean, validator); + } + +} diff --git a/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/ExamplePropertyBean.java b/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/ExamplePropertyBean.java new file mode 100644 index 000000000..3aec7eef2 --- /dev/null +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/bean/impl/example/ExamplePropertyBean.java @@ -0,0 +1,41 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.bean.impl.example; + +import javax.inject.Inject; +import javax.inject.Named; + +import net.sf.mmm.util.bean.api.Bean; +import net.sf.mmm.util.lang.api.Orientation; +import net.sf.mmm.util.property.api.WritableProperty; +import net.sf.mmm.util.property.api.lang.IntegerProperty; +import net.sf.mmm.util.property.api.lang.WritableBooleanProperty; +import net.sf.mmm.util.property.api.lang.WritableIntegerProperty; +import net.sf.mmm.util.property.api.lang.WritableStringProperty; +import net.sf.mmm.util.validation.base.Mandatory; + +/** + * TODO: this class ... + * + * @author hohwille + */ +@Named("RenamedBean") +public interface ExamplePropertyBean extends Bean { + + CountryCodeProperty CountryCode(); + + @Mandatory + @Named("Alias") + WritableStringProperty Name(); + + @Inject + default WritableIntegerProperty Age() { + + return new IntegerProperty(null, null).withValdidator().mandatory().range(0, 200).and().build(); + } + + WritableBooleanProperty Friend(); + + WritableProperty Orientation(); + +} diff --git a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/AbstractStatementTest.java b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/AbstractStatementTest.java similarity index 84% rename from mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/AbstractStatementTest.java rename to mmm-util-query/src/test/java/net/sf/mmm/util/query/base/AbstractStatementTest.java index 2503d5202..1288a2da7 100644 --- a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/AbstractStatementTest.java +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/AbstractStatementTest.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.ArrayList; import java.util.HashSet; @@ -16,16 +16,21 @@ import net.sf.mmm.util.bean.impl.example.ExampleBean; import net.sf.mmm.util.lang.api.Orientation; import net.sf.mmm.util.property.api.path.PropertyPath; -import net.sf.mmm.util.property.api.query.Statement; -import net.sf.mmm.util.property.api.query.feature.FeatureGroupBy; -import net.sf.mmm.util.property.api.query.feature.FeatureLimit; -import net.sf.mmm.util.property.api.query.feature.FeatureOrderBy; -import net.sf.mmm.util.property.api.query.feature.FeaturePaging; -import net.sf.mmm.util.property.api.query.feature.FeatureSet; -import net.sf.mmm.util.property.api.query.feature.FeatureValues; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; -import net.sf.mmm.util.property.api.query.feature.StatementFeature; import net.sf.mmm.util.property.base.expression.Expressions; +import net.sf.mmm.util.query.api.Statement; +import net.sf.mmm.util.query.api.feature.FeatureGroupBy; +import net.sf.mmm.util.query.api.feature.FeatureLimit; +import net.sf.mmm.util.query.api.feature.FeatureOrderBy; +import net.sf.mmm.util.query.api.feature.FeaturePaging; +import net.sf.mmm.util.query.api.feature.FeatureSet; +import net.sf.mmm.util.query.api.feature.FeatureValues; +import net.sf.mmm.util.query.api.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.StatementFeature; +import net.sf.mmm.util.query.base.AbstractSelectStatement; +import net.sf.mmm.util.query.base.AbstractStatement; +import net.sf.mmm.util.query.base.DefaultSqlDialect; +import net.sf.mmm.util.query.base.SqlDialect; +import net.sf.mmm.util.query.base.jpql.JpqlDialect; /** * Test of {@link Statement} and {@link AbstractStatement}. @@ -157,12 +162,19 @@ protected String checkSet(S statement, String sql, List variables) { return sql; } // add assignment to SET clause - ExampleBean prototpye = getPrototype(); Long age = 18L; String sqlSet = sql + " SET " + quote(statement, "Age") + " = " + variable(statement, variables, age); - set.set(prototpye.Age(), age); + set.set(this.prototype.Age(), age); assertThat(statement.getSql()).isEqualTo(sqlSet); assertThat(statement.getVariables()).containsExactlyElementsOf(variables); + + // add 2nd assignment to SET clause + String name = "Superman"; + sqlSet = sqlSet + ", " + quote(statement, "Name") + " = " + quote(statement, "CountryCode"); + set.set(this.prototype.Name(), this.prototype.CountryCode()); + assertThat(statement.getSql()).isEqualTo(sqlSet); + assertThat(statement.getVariables()).containsExactlyElementsOf(variables); + return sqlSet; } @@ -173,7 +185,23 @@ protected String checkValues(S statement, String sql, List variables) { return sql; } - return sql; + // add assignment to SET clause + boolean friend = true; + String sqlValues = sql + " (" + quote(statement, "Friend") + ") VALUES (" + + variable(statement, variables, friend) + ")"; + values.value(this.prototype.Friend(), friend); + assertThat(statement.getSql()).isEqualTo(sqlValues); + assertThat(statement.getVariables()).containsExactlyElementsOf(variables); + + // add 2nd assignment to SET clause + Orientation orientation = Orientation.HORIZONTAL; + sqlValues = sql + " (" + quote(statement, "Friend") + ", " + quote(statement, "Orientaton") + ") VALUES (" + + variable(statement, variables, friend) + ", " + variable(statement, variables, orientation) + ")"; + values.value(this.prototype.Orientation(), orientation); + assertThat(statement.getSql()).isEqualTo(sqlValues); + assertThat(statement.getVariables()).containsExactlyElementsOf(variables); + + return sqlValues; } protected String checkWhere(S statement, String sql, List variables) { diff --git a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/DeleteStatementTest.java b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/DeleteStatementTest.java similarity index 75% rename from mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/DeleteStatementTest.java rename to mmm-util-query/src/test/java/net/sf/mmm/util/query/base/DeleteStatementTest.java index 128683da1..c8721fbfb 100644 --- a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/DeleteStatementTest.java +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/DeleteStatementTest.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.Arrays; import java.util.List; @@ -8,12 +8,15 @@ import net.sf.mmm.util.bean.api.Bean; import net.sf.mmm.util.bean.api.BeanFactory; import net.sf.mmm.util.bean.impl.example.ExampleBean; -import net.sf.mmm.util.property.api.query.SelectStatement; -import net.sf.mmm.util.property.api.query.feature.FeatureLimit; -import net.sf.mmm.util.property.api.query.feature.FeatureModify; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; -import net.sf.mmm.util.property.api.query.feature.StatementFeature; -import net.sf.mmm.util.property.base.query.DeleteStatementTest.TestDeleteStatement; +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureLimit; +import net.sf.mmm.util.query.api.feature.FeatureModify; +import net.sf.mmm.util.query.api.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.StatementFeature; +import net.sf.mmm.util.query.base.AbstractDeleteStatement; +import net.sf.mmm.util.query.base.AbstractSelectStatement; +import net.sf.mmm.util.query.base.SqlDialect; +import net.sf.mmm.util.query.base.DeleteStatementTest.TestDeleteStatement; /** * Test of {@link SelectStatement} and {@link AbstractSelectStatement}. diff --git a/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/InsertStatementTest.java b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/InsertStatementTest.java new file mode 100644 index 000000000..ab0de5a66 --- /dev/null +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/InsertStatementTest.java @@ -0,0 +1,82 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.query.base; + +import java.util.Arrays; +import java.util.List; + +import net.sf.mmm.util.bean.api.Bean; +import net.sf.mmm.util.bean.api.BeanFactory; +import net.sf.mmm.util.bean.impl.example.ExampleBean; +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureModify; +import net.sf.mmm.util.query.api.feature.FeatureSet; +import net.sf.mmm.util.query.api.feature.StatementFeature; +import net.sf.mmm.util.query.base.AbstractInsertStatement; +import net.sf.mmm.util.query.base.AbstractSelectStatement; +import net.sf.mmm.util.query.base.SqlDialect; +import net.sf.mmm.util.query.base.InsertStatementTest.TestInsertStatement; + +/** + * Test of {@link SelectStatement} and {@link AbstractSelectStatement}. + * + * @author hohwille + */ +public class InsertStatementTest extends AbstractStatementTest> { + + @Override + protected TestInsertStatement createStatement(SqlDialect dialect) { + + return new TestInsertStatement<>(getPrototype(), dialect); + } + + @Override + protected List> getFeatures() { + + return Arrays.asList(FeatureModify.class, FeatureSet.class); + } + + @Override + protected String getSqlStart() { + + return "INSERT INTO "; + } + + public static class TestInsertStatement + extends AbstractInsertStatement> { + + private final E prototype; + + /** + * The constructor. + * + * @param prototype the {@link Bean}-{@link BeanFactory#getPrototype(Bean) prototype}. + */ + public TestInsertStatement(E prototype, SqlDialect dialect) { + super(dialect); + this.prototype = prototype; + } + + /** + * @return the prototype + */ + public E getPrototype() { + + return this.prototype; + } + + @Override + protected String getSource() { + + return this.prototype.access().getSimpleName(); + } + + @Override + public long execute() { + + throw new UnsupportedOperationException(); + } + + } + +} diff --git a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/SelectStatementTest.java b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/SelectStatementTest.java similarity index 79% rename from mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/SelectStatementTest.java rename to mmm-util-query/src/test/java/net/sf/mmm/util/query/base/SelectStatementTest.java index b8f27b565..cbc776732 100644 --- a/mmm-util-property/src/test/java/net/sf/mmm/util/property/base/query/SelectStatementTest.java +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/SelectStatementTest.java @@ -1,6 +1,6 @@ /* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 * http://www.apache.org/licenses/LICENSE-2.0 */ -package net.sf.mmm.util.property.base.query; +package net.sf.mmm.util.query.base; import java.util.Arrays; import java.util.List; @@ -8,13 +8,15 @@ import net.sf.mmm.util.bean.api.Bean; import net.sf.mmm.util.bean.api.BeanFactory; import net.sf.mmm.util.bean.impl.example.ExampleBean; -import net.sf.mmm.util.property.api.query.SelectStatement; -import net.sf.mmm.util.property.api.query.feature.FeatureFetch; -import net.sf.mmm.util.property.api.query.feature.FeatureGroupBy; -import net.sf.mmm.util.property.api.query.feature.FeatureOrderBy; -import net.sf.mmm.util.property.api.query.feature.FeaturePaging; -import net.sf.mmm.util.property.api.query.feature.FeatureWhere; -import net.sf.mmm.util.property.api.query.feature.StatementFeature; +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureFetch; +import net.sf.mmm.util.query.api.feature.FeatureGroupBy; +import net.sf.mmm.util.query.api.feature.FeatureOrderBy; +import net.sf.mmm.util.query.api.feature.FeaturePaging; +import net.sf.mmm.util.query.api.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.StatementFeature; +import net.sf.mmm.util.query.base.AbstractSelectStatement; +import net.sf.mmm.util.query.base.SqlDialect; /** * Test of {@link SelectStatement} and {@link AbstractSelectStatement}. diff --git a/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/UpdateStatementTest.java b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/UpdateStatementTest.java new file mode 100644 index 000000000..e1a63fb82 --- /dev/null +++ b/mmm-util-query/src/test/java/net/sf/mmm/util/query/base/UpdateStatementTest.java @@ -0,0 +1,84 @@ +/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 */ +package net.sf.mmm.util.query.base; + +import java.util.Arrays; +import java.util.List; + +import net.sf.mmm.util.bean.api.Bean; +import net.sf.mmm.util.bean.api.BeanFactory; +import net.sf.mmm.util.bean.impl.example.ExampleBean; +import net.sf.mmm.util.query.api.SelectStatement; +import net.sf.mmm.util.query.api.feature.FeatureLimit; +import net.sf.mmm.util.query.api.feature.FeatureModify; +import net.sf.mmm.util.query.api.feature.FeatureSet; +import net.sf.mmm.util.query.api.feature.FeatureWhere; +import net.sf.mmm.util.query.api.feature.StatementFeature; +import net.sf.mmm.util.query.base.AbstractSelectStatement; +import net.sf.mmm.util.query.base.AbstractUpdateStatement; +import net.sf.mmm.util.query.base.SqlDialect; +import net.sf.mmm.util.query.base.UpdateStatementTest.TestUpdateStatement; + +/** + * Test of {@link SelectStatement} and {@link AbstractSelectStatement}. + * + * @author hohwille + */ +public class UpdateStatementTest extends AbstractStatementTest> { + + @Override + protected TestUpdateStatement createStatement(SqlDialect dialect) { + + return new TestUpdateStatement<>(getPrototype(), dialect); + } + + @Override + protected List> getFeatures() { + + return Arrays.asList(FeatureWhere.class, FeatureLimit.class, FeatureModify.class, FeatureSet.class); + } + + @Override + protected String getSqlStart() { + + return "UPDATE "; + } + + public static class TestUpdateStatement + extends AbstractUpdateStatement> { + + private final E prototype; + + /** + * The constructor. + * + * @param prototype the {@link Bean}-{@link BeanFactory#getPrototype(Bean) prototype}. + */ + public TestUpdateStatement(E prototype, SqlDialect dialect) { + super(dialect); + this.prototype = prototype; + } + + /** + * @return the prototype + */ + public E getPrototype() { + + return this.prototype; + } + + @Override + protected String getSource() { + + return this.prototype.access().getSimpleName(); + } + + @Override + public long execute() { + + throw new UnsupportedOperationException(); + } + + } + +}