Skip to content

Commit

Permalink
#177: fixed travis error
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Apr 13, 2016
1 parent 287eca4 commit dbdf406
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* Extends a regular {@link SelectStatement} with advanced features like
* {@link #having(net.sf.mmm.util.property.api.expression.Expression...) HAVING clause}.
* {@link #having(net.sf.mmm.util.query.api.expression.Expression...) HAVING clause}.
*
* @param <E> the generic type of the queried object (typically a {@link net.sf.mmm.util.bean.api.Bean}).
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* 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.statement.jpql;

import javax.persistence.Entity;

import net.sf.mmm.util.query.base.path.Alias;

/**
* Helper class with {@link JpqlDialect JPQL} specific functions.
*
* @author hohwille
* @since 8.0.0
*/
public final class Jpql {

private Jpql() {
}

/**
* @param <E> the generic type of the {@link Entity} {@link Class}.
* @param entityClass the {@link Entity} {@link Class}.
* @return the corresponding {@link Alias}.
*/
public static <E> Alias<E> alias(Class<E> entityClass) {

String entityName = entityClass.getSimpleName();
Entity entity = entityClass.getAnnotation(Entity.class);
if (entity != null) {
String name = entity.name();
if (!name.isEmpty()) {
entityName = name;
}
}
return new Alias<>(entityName, null, entityClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
Expand Down Expand Up @@ -36,20 +35,12 @@ public class JpqlSelectStatementImpl<E> extends AbstractSelectStatement<E, JpqlS
* The constructor.
*
* @param entityManager the {@link EntityManager} instance.
* @param entityClass the {@link Class} reflecting the {@link Entity}.
* @param alias the {@link Alias}.
*/
public JpqlSelectStatementImpl(EntityManager entityManager, Alias<E> alias) {
super(JpqlDialect.INSTANCE, alias);
this.entityManager = entityManager;
this.entityClass = this.entityClass;
String entityName = this.entityClass.getSimpleName();
Entity entity = this.entityClass.getAnnotation(Entity.class);
if (entity != null) {
String name = entity.name();
if (!name.isEmpty()) {
entityName = name;
}
}
this.entityClass = alias.getType();
}

private Query query(String prefix) {
Expand Down

0 comments on commit dbdf406

Please sign in to comment.