Skip to content

Commit

Permalink
hohwille/query#1: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Oct 17, 2017
1 parent 9955b3c commit 44a84b0
Show file tree
Hide file tree
Showing 17 changed files with 89 additions and 71 deletions.
4 changes: 2 additions & 2 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<!-- BOM of mmm-l10n -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mmm-util-bom</artifactId>
<version>${net.sf.mmm.util.version}</version>
<artifactId>mmm-query-bom</artifactId>
<version>${net.sf.mmm.query.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
6 changes: 5 additions & 1 deletion main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mmm-util-query</artifactId>
<artifactId>mmm-query-impl</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mmm-util-data</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.jpa.api.query.statenent.jpql;

import net.sf.mmm.util.query.api.statement.DeleteStatement;
import net.sf.mmm.query.api.statement.DeleteStatement;

/**
* Extension of a regular {@link DeleteStatement} for {@link net.sf.mmm.jpa.base.query.statement.jpql.Jpql JPQL}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.jpa.api.query.statenent.jpql;

import net.sf.mmm.util.query.api.feature.FeatureAndFrom;
import net.sf.mmm.util.query.api.feature.FeatureHaving;
import net.sf.mmm.util.query.api.statement.SelectStatement;
import net.sf.mmm.query.api.feature.FeatureAndFrom;
import net.sf.mmm.query.api.feature.FeatureHaving;
import net.sf.mmm.query.api.statement.SelectStatement;

/**
* Extends a regular {@link SelectStatement} with advanced features like
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.jpa.api.query.statenent.jpql;

import net.sf.mmm.property.api.path.PropertyPath;
import net.sf.mmm.query.api.feature.FeatureInsert;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.api.statement.StatementFactory;
import net.sf.mmm.util.component.api.ComponentSpecification;
import net.sf.mmm.util.property.api.path.PropertyPath;
import net.sf.mmm.util.query.api.feature.FeatureInsert;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.api.statement.StatementFactory;

/**
* This is the interface extends {@link StatementFactory} for {@link net.sf.mmm.jpa.base.query.statement.jpql.Jpql}.
* There is no {@link FeatureInsert INSERT support} as JPQL does not have insert statements.
* This is the interface extends {@link StatementFactory} for
* {@link net.sf.mmm.jpa.base.query.statement.jpql.Jpql}. There is no {@link FeatureInsert INSERT support} as
* JPQL does not have insert statements.
*
* @author hohwille
* @since 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.jpa.api.query.statenent.jpql;

import net.sf.mmm.util.query.api.statement.UpdateStatement;
import net.sf.mmm.query.api.statement.UpdateStatement;

/**
* Extension of a regular {@link UpdateStatement} for {@link net.sf.mmm.jpa.base.query.statement.jpql.Jpql JPQL}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

import javax.persistence.Entity;

import net.sf.mmm.util.bean.api.Bean;
import net.sf.mmm.util.bean.api.BeanFactory;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.base.path.Alias;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.base.path.Alias;

/**
* Helper class with {@link JpqlDialect JPQL} specific functions.
Expand All @@ -33,9 +31,10 @@ public static <E> EntityAlias<E> alias(Class<E> entityClass) {
/**
* @param <T> the generic type of the common {@link net.sf.mmm.util.data.api.entity.Entity} interface.
* @param <E> the generic type of the JPA {@link Entity} {@link Class}.
* @param <B> the generic type of the {@link net.sf.mmm.util.bean.api.entity.EntityBean} interface.
* @param <B> the generic type of the {@link net.sf.mmm.bean.api.entity.EntityBean} interface.
* @param entityClass the {@link Entity} {@link Class}.
* @param beanPrototype the {@link Bean} {@link BeanFactory#createPrototype(Class) prototype}.
* @param beanPrototype the {@link net.sf.mmm.bean.api.Bean}
* {@link net.sf.mmm.bean.api.BeanFactory#createPrototype(Class) prototype}.
* @return the corresponding {@link EntityAlias}.
*/
public static <T, E extends T, B extends T> EntityAlias<B> alias(Class<E> entityClass, B beanPrototype) {
Expand All @@ -47,10 +46,11 @@ public static <T, E extends T, B extends T> EntityAlias<B> alias(Class<E> entity
/**
* @param <T> the generic type of the common {@link net.sf.mmm.util.data.api.entity.Entity} interface.
* @param <E> the generic type of the JPA {@link Entity} {@link Class}.
* @param <B> the generic type of the {@link net.sf.mmm.util.bean.api.entity.EntityBean} interface.
* @param <B> the generic type of the {@link net.sf.mmm.bean.api.entity.EntityBean} interface.
* @param entityInterface the {@link net.sf.mmm.util.data.api.entity.Entity} interface.
* @param entityClass the {@link Entity} {@link Class}.
* @param beanPrototype the {@link Bean} {@link BeanFactory#createPrototype(Class) prototype}.
* @param beanPrototype the {@link net.sf.mmm.bean.api.Bean}
* {@link net.sf.mmm.bean.api.BeanFactory#createPrototype(Class) prototype}.
* @return the corresponding {@link EntityAlias}.
*/
public static <T, E extends T, B extends T> EntityAlias<T> alias(Class<T> entityInterface, Class<E> entityClass, B beanPrototype) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* http://www.apache.org/licenses/LICENSE-2.0 */
package net.sf.mmm.jpa.base.query.statement.jpql;

import net.sf.mmm.util.property.api.ReadableProperty;
import net.sf.mmm.util.query.base.statement.SqlDialect;
import net.sf.mmm.property.api.ReadableProperty;
import net.sf.mmm.query.api.statement.SqlDialect;

/**
* The implementation of {@link SqlDialect} for
* <a href="http://docs.oracle.com/cd/E12839_01/apirefs.1111/e13946/ejb3_langref.html">Java Persistence Query Language
* (JPQL)</a>.
* <a href="http://docs.oracle.com/cd/E12839_01/apirefs.1111/e13946/ejb3_langref.html">Java Persistence Query
* Language (JPQL)</a>.
*
* @author hohwille
* @since 1.0.0
Expand All @@ -22,6 +22,7 @@ public class JpqlDialect extends Object implements SqlDialect {
* The constructor.
*/
public JpqlDialect() {

super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import net.sf.mmm.bean.impl.spring.BeanSpringConfig;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlStatementFactory;
import net.sf.mmm.jpa.impl.query.statement.jpql.JpqlStatementFactoryImpl;
import net.sf.mmm.util.bean.impl.spring.UtilBeanSpringConfig;

/**
* This is the Spring {@link Configuration} for {@link net.sf.mmm.util.pojo}.
Expand All @@ -17,7 +17,7 @@
* @since 1.0.0
*/
@Configuration
@Import(UtilBeanSpringConfig.class)
@Import(BeanSpringConfig.class)
@SuppressWarnings("javadoc")
public class UtilQueryJpqlSpringConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import javax.persistence.Query;

import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlDeleteStatement;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.base.statement.AbstractDeleteStatement;
import net.sf.mmm.util.query.base.statement.SqlDialect;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.api.statement.SqlDialect;
import net.sf.mmm.query.base.statement.AbstractDeleteStatement;

/**
* Implementation of {@link JpqlDeleteStatement}.
*
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}).
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.bean.api.Bean}).
*
* @author hohwille
* @since 1.0.0
Expand All @@ -30,6 +30,7 @@ public class JpqlDeleteStatementImpl<E> extends AbstractDeleteStatement<E, JpqlD
* @param alias - see {@link #getAlias()}.
*/
public JpqlDeleteStatementImpl(EntityManager entityManager, SqlDialect dialect, EntityAlias<E> alias) {

super(dialect, alias);
this.entityManager = entityManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@

import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlSelectStatement;
import net.sf.mmm.jpa.base.query.statement.jpql.JpqlDialect;
import net.sf.mmm.util.property.api.path.PropertyPath;
import net.sf.mmm.util.query.api.expression.Expression;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.api.path.Path;
import net.sf.mmm.util.query.base.QueryMode;
import net.sf.mmm.util.query.base.feature.FeatureAndFromImpl;
import net.sf.mmm.util.query.base.feature.FeatureHavingImpl;
import net.sf.mmm.util.query.base.statement.AbstractSelectStatement;
import net.sf.mmm.util.query.base.statement.SqlDialect;
import net.sf.mmm.property.api.path.PropertyPath;
import net.sf.mmm.query.api.expression.Expression;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.api.path.Path;
import net.sf.mmm.query.api.statement.SqlDialect;
import net.sf.mmm.query.base.QueryMode;
import net.sf.mmm.query.base.feature.FeatureAndFromImpl;
import net.sf.mmm.query.base.feature.FeatureHavingImpl;
import net.sf.mmm.query.base.statement.AbstractSelectStatement;

/**
* Implementation of {@link JpqlSelectStatement}.
*
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}).
* @param <T> the generic type of the {@link #execute(String, QueryMode) internal results}. See {@link #getMapper()}.
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.bean.api.Bean}).
* @param <T> the generic type of the {@link #execute(String, QueryMode) internal results}. See
* {@link #getMapper()}.
*
* @author hohwille
* @since 1.0.0
Expand All @@ -41,6 +42,7 @@ public class JpqlSelectStatementImpl<E, T> extends AbstractSelectStatement<E, Jp
* @param mapper - see {@link #getMapper()}.
*/
public JpqlSelectStatementImpl(EntityManager entityManager, JpqlDialect dialect, EntityAlias<E> alias, Function<T, E> mapper) {

super(dialect, alias, mapper);
this.entityManager = entityManager;
}
Expand All @@ -53,12 +55,13 @@ public JpqlSelectStatementImpl(EntityManager entityManager, JpqlDialect dialect,
* @param alias - see {@link #getAlias()}.
* @param mapper - see {@link #getMapper()}.
* @param toClass - see
* {@link net.sf.mmm.util.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* {@link net.sf.mmm.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* @param constructorArgs - see
* {@link net.sf.mmm.util.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* {@link net.sf.mmm.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
*/
public JpqlSelectStatementImpl(EntityManager entityManager, SqlDialect dialect, EntityAlias<?> alias, Function<T, E> mapper, Class<E> toClass,
PropertyPath<?>... constructorArgs) {

super(dialect, alias, mapper, toClass, constructorArgs);
this.entityManager = entityManager;
}
Expand All @@ -75,6 +78,7 @@ public JpqlSelectStatementImpl(EntityManager entityManager, SqlDialect dialect,
* .
*/
public JpqlSelectStatementImpl(EntityManager entityManager, SqlDialect dialect, EntityAlias<?> alias, Function<T, E> mapper, PropertyPath<?>... paths) {

super(dialect, alias, mapper, paths);
this.entityManager = entityManager;
}
Expand All @@ -87,10 +91,11 @@ public JpqlSelectStatementImpl(EntityManager entityManager, SqlDialect dialect,
* @param alias - see {@link #getAlias()}.
* @param mapper - see {@link #getMapper()}.
* @param paths - see
* {@link net.sf.mmm.util.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, PropertyPath...)}
* {@link net.sf.mmm.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, PropertyPath...)}
* .
*/
public JpqlSelectStatementImpl(EntityManager entityManager, JpqlDialect dialect, EntityAlias<?> alias, Function<T, E> mapper, PropertyPath<?>... paths) {

super(dialect, alias, mapper, paths);
this.entityManager = entityManager;
}
Expand All @@ -103,12 +108,13 @@ public JpqlSelectStatementImpl(EntityManager entityManager, JpqlDialect dialect,
* @param alias - see {@link #getAlias()}.
* @param mapper - see {@link #getMapper()}.
* @param toClass - see
* {@link net.sf.mmm.util.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* {@link net.sf.mmm.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* @param constructorArgs - see
* {@link net.sf.mmm.util.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
* {@link net.sf.mmm.query.api.statement.StatementFactory#selectFrom(EntityAlias, Class, Path...)}.
*/
public JpqlSelectStatementImpl(EntityManager entityManager, JpqlDialect dialect, EntityAlias<?> alias, Function<T, E> mapper, Class<E> toClass,
PropertyPath<?>... constructorArgs) {

super(dialect, alias, mapper, toClass, constructorArgs);
this.entityManager = entityManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import net.sf.mmm.bean.api.Bean;
import net.sf.mmm.bean.api.mapping.GenericPojoBeanMapper;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlDeleteStatement;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlSelectStatement;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlStatementFactory;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlUpdateStatement;
import net.sf.mmm.jpa.base.query.statement.jpql.JpqlDialect;
import net.sf.mmm.util.bean.api.Bean;
import net.sf.mmm.util.bean.api.mapping.GenericPojoBeanMapper;
import net.sf.mmm.util.property.api.path.PropertyPath;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.base.statement.AbstractStatement;
import net.sf.mmm.util.query.base.statement.AbstractStatementFactory;
import net.sf.mmm.property.api.path.PropertyPath;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.base.statement.AbstractStatement;
import net.sf.mmm.query.base.statement.AbstractStatementFactory;

/**
* This is the interface
Expand All @@ -40,6 +40,7 @@ public class JpqlStatementFactoryImpl extends AbstractStatementFactory implement
* The constructor.
*/
public JpqlStatementFactoryImpl() {

this(null, JpqlDialect.INSTANCE);
}

Expand All @@ -49,6 +50,7 @@ public JpqlStatementFactoryImpl() {
* @param dialect the {@link JpqlDialect}.
*/
public JpqlStatementFactoryImpl(JpqlDialect dialect) {

this(null, dialect);
}

Expand All @@ -58,6 +60,7 @@ public JpqlStatementFactoryImpl(JpqlDialect dialect) {
* @param entityManager the {@link EntityManager}.
*/
public JpqlStatementFactoryImpl(EntityManager entityManager) {

this(entityManager, JpqlDialect.INSTANCE);
}

Expand All @@ -68,6 +71,7 @@ public JpqlStatementFactoryImpl(EntityManager entityManager) {
* @param dialect the {@link JpqlDialect}.
*/
public JpqlStatementFactoryImpl(EntityManager entityManager, JpqlDialect dialect) {

super();
this.entityManager = entityManager;
this.dialect = dialect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import javax.persistence.Query;

import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlUpdateStatement;
import net.sf.mmm.util.query.api.path.EntityAlias;
import net.sf.mmm.util.query.base.feature.FeatureSetImpl;
import net.sf.mmm.util.query.base.statement.AbstractUpdateStatement;
import net.sf.mmm.util.query.base.statement.SqlDialect;
import net.sf.mmm.query.api.path.EntityAlias;
import net.sf.mmm.query.api.statement.SqlDialect;
import net.sf.mmm.query.base.feature.FeatureSetImpl;
import net.sf.mmm.query.base.statement.AbstractUpdateStatement;

/**
* Implementation of {@link JpqlUpdateStatement}.
*
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}).
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.bean.api.Bean}).
*
* @author hohwille
* @since 1.0.0
Expand All @@ -31,6 +31,7 @@ public class JpqlUpdateStatementImpl<E> extends AbstractUpdateStatement<E, JpqlU
* @param alias - see {@link #getAlias()}.
*/
public JpqlUpdateStatementImpl(EntityManager entityManager, SqlDialect dialect, EntityAlias<E> alias) {

super(dialect, alias);
this.entityManager = entityManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import net.sf.mmm.bean.impl.spring.BeanSpringConfig;
import net.sf.mmm.jpa.api.query.statenent.jpql.JpqlStatementFactory;
import net.sf.mmm.jpa.base.query.statement.jpql.UnquotedJpqlDialect;
import net.sf.mmm.jpa.impl.query.statement.jpql.JpqlStatementFactoryImpl;
import net.sf.mmm.util.bean.impl.spring.UtilBeanSpringConfig;

/**
* Spring {@link Configuration} for the tests.
*/
@Configuration
@Import(UtilBeanSpringConfig.class)
@Import(BeanSpringConfig.class)
@EntityScan
@SpringBootApplication
public class SpringTestConfig {
Expand Down
Loading

0 comments on commit 44a84b0

Please sign in to comment.