Skip to content

Commit

Permalink
Small Spring restructurings. Improve cyclic join error message. Unwra…
Browse files Browse the repository at this point in the history
…p object array when using a PaginatedCriteriaBuilder with keyset extraction without an object builder. Align Spring Data with Deltaspike Data regarding ad-hoc entity view usage. Update version numbers everywhere to the 3 part variant. Remove emails from author tags
  • Loading branch information
beikov committed Mar 8, 2018
1 parent 4522030 commit dbfe36f
Show file tree
Hide file tree
Showing 681 changed files with 2,340 additions and 1,027 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.blazebit.persistence.view.EntityViewManager;
import com.blazebit.persistence.view.spi.EntityViewConfiguration;
import com.blazebit.persistence.view.spring.impl.EnableEntityViews;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -38,7 +38,7 @@
@EnableEntityViews(basePackages = { "${package}.view"})
@EnableJpaRepositories(
basePackages = "${package}.repository",
repositoryFactoryBeanClass = EntityViewRepositoryFactoryBean.class)
repositoryFactoryBeanClass = BlazePersistenceRepositoryFactoryBean.class)
public class BlazePersistenceConfiguration {

@PersistenceUnit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.springframework.beans.factory.annotation.*;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import com.blazebit.persistence.view.spring.impl.EnableEntityViews;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SampleTest.TestConfig.class)
Expand All @@ -58,7 +58,7 @@ public void sampleTest() {
@EnableJpaRepositories(
basePackages = "${package}.repository",
entityManagerFactoryRef = "myEmf",
repositoryFactoryBeanClass = EntityViewRepositoryFactoryBean.class)
repositoryFactoryBeanClass = BlazePersistenceRepositoryFactoryBean.class)
static class TestConfig {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.blazebit.persistence.view.EntityViewManager;
import com.blazebit.persistence.view.spi.EntityViewConfiguration;
import com.blazebit.persistence.view.spring.impl.EnableEntityViews;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -38,7 +38,7 @@
@EnableEntityViews(basePackages = { "${package}.view"})
@EnableJpaRepositories(
basePackages = "${package}.repository",
repositoryFactoryBeanClass = EntityViewRepositoryFactoryBean.class)
repositoryFactoryBeanClass = BlazePersistenceRepositoryFactoryBean.class)
public class BlazePersistenceConfiguration {

@PersistenceUnit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.springframework.beans.factory.annotation.*;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import com.blazebit.persistence.view.spring.impl.EnableEntityViews;
import com.blazebit.persistence.spring.data.impl.repository.EntityViewRepositoryFactoryBean;
import com.blazebit.persistence.spring.data.impl.repository.BlazePersistenceRepositoryFactoryBean;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SampleTest.TestConfig.class)
Expand All @@ -58,7 +58,7 @@ public void sampleTest() {
@EnableJpaRepositories(
basePackages = "${package}.repository",
entityManagerFactoryRef = "myEmf",
repositoryFactoryBeanClass = EntityViewRepositoryFactoryBean.class)
repositoryFactoryBeanClass = BlazePersistenceRepositoryFactoryBean.class)
static class TestConfig {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
* @param <SubquerySetReturn> The builder type that should be returned on subquery set operations
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public abstract class AbstractCommonQueryBuilder<QueryResultType, BuilderType, SetReturn, SubquerySetReturn, FinalSetReturn extends BaseFinalSetOperationBuilderImpl<?, ?, ?>> implements ServiceProvider, ConfigurationSource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @param <X> The concrete builder type
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public abstract class AbstractFullQueryBuilder<T, X extends FullQueryBuilder<T, X>, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl<T, ?, ?>> extends AbstractQueryBuilder<T, X, Z, W, FinalSetReturn> implements FullQueryBuilder<T, X> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public abstract class AbstractManager<T extends ExpressionModifier> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @param <X> The concrete builder type
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public abstract class AbstractQueryBuilder<T, X extends Queryable<T, X>, Z, W, FinalSetReturn extends BaseFinalSetOperationBuilderImpl<T, ?, ?>> extends AbstractCommonQueryBuilder<T, X, Z, W, FinalSetReturn> implements Queryable<T, X> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public interface AliasInfo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class AliasManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public abstract class BaseSubqueryBuilderImpl<T, X, Y extends BaseOngoingSetOperationBuilder<?, ?, ?>, Z extends BaseOngoingSetOperationBuilder<?, ?, ?>> extends AbstractCommonQueryBuilder<Tuple, X, Y, Z, BaseFinalSetOperationSubqueryBuilderImpl<T, ?>> implements SubqueryInternalBuilder<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public final class ConfigurationProperties {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class CriteriaBuilderConfigurationImpl implements CriteriaBuilderConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
*
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class CriteriaBuilderConfigurationProviderImpl implements CriteriaBuilderConfigurationProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/**
*
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class CriteriaBuilderFactoryImpl implements CriteriaBuilderFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @param <T> The query result type
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class CriteriaBuilderImpl<T> extends AbstractFullQueryBuilder<T, CriteriaBuilder<T>, LeafOngoingSetOperationCriteriaBuilder<T>, StartOngoingSetOperationCriteriaBuilder<T, LeafOngoingFinalSetOperationCriteriaBuilder<T>>, BaseFinalSetOperationCriteriaBuilderImpl<T, ?>> implements CriteriaBuilder<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class ExpressionUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class ExternalAliasDereferencingException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class GroupByManager extends AbstractManager<ExpressionModifier> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class HavingManager<T> extends PredicateManager<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author Moritz Becker
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class IllegalSubqueryDetector extends VisitorAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class JoinAliasInfo implements AliasInfo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
/**
* @author Moritz Becker
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class JoinManager extends AbstractManager<ExpressionModifier> {

Expand Down Expand Up @@ -1104,8 +1104,19 @@ private void renderReverseDependency(StringBuilder sb, JoinNode dependency, Stri
try {
for (JoinNode dep : dependency.getDependencies()) {
if (markedJoinNodes.contains(dep)) {
throw new IllegalStateException("Cyclic join dependency detected at absolute path ["
+ dep.getAliasInfo().getAbsolutePath() + "] with alias [" + dep.getAliasInfo().getAlias() + "]");
StringBuilder errorSb = new StringBuilder();
errorSb.append("Cyclic join dependency between nodes: [");
for (JoinNode seenNode : markedJoinNodes) {
errorSb.append(seenNode.getAliasInfo().getAlias());
if (seenNode.getAliasInfo().isImplicit()) {
errorSb.append('(').append(seenNode.getAliasInfo().getAbsolutePath()).append(')');
}
errorSb.append(", ");
}
errorSb.setLength(errorSb.length() - 2);
errorSb.append(']');

throw new IllegalStateException(errorSb.toString());
}
// render reverse dependencies
renderReverseDependency(sb, dep, aliasPrefix, renderFetches, nodesToFetch, whereConjuncts);
Expand Down Expand Up @@ -1720,7 +1731,11 @@ public void implicitJoin(Expression expression, boolean objectLeafAllowed, Strin

// Don't forget to update the clause dependencies!!
if (fromClause != null) {
updateClauseDependencies(result.baseNode, fromClause, new HashSet<JoinNode>());
try {
updateClauseDependencies(result.baseNode, fromClause, new LinkedHashSet<JoinNode>());
} catch (IllegalStateException ex) {
throw new IllegalArgumentException("Implicit join in expression '" + expression + "' introduces cyclic join dependency!", ex);
}
}

if (result.isLazy()) {
Expand Down Expand Up @@ -2253,8 +2268,18 @@ private JoinResult implicitJoinSingle(JoinNode baseNode, String attributeName, b

private void updateClauseDependencies(JoinNode baseNode, ClauseType clauseDependency, Set<JoinNode> seenNodes) {
if (!seenNodes.add(baseNode)) {
// Cyclic dependency
throw new IllegalStateException("Cyclic join dependency: " + seenNodes);
StringBuilder errorSb = new StringBuilder();
errorSb.append("Cyclic join dependency between nodes: ");
for (JoinNode seenNode : seenNodes) {
errorSb.append(seenNode.getAliasInfo().getAlias());
if (seenNode.getAliasInfo().isImplicit()) {
errorSb.append('(').append(seenNode.getAliasInfo().getAbsolutePath()).append(')');
}
errorSb.append(" -> ");
}
errorSb.setLength(errorSb.length() - 4);

throw new IllegalStateException(errorSb.toString());
}

JoinNode current = baseNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class JoinNode implements From, ExpressionModifier, BaseNode {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public interface JoinNodeVisitor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
*
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class JoinTreeNode {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class JoinVisitor extends VisitorAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
*
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public final class JpaUtils {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @author Moritz Becker
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public class NodeInfo implements ExpressionModifier {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
*
* @author Christian Beikov
* @since 1.0
* @since 1.0.0
*/
public final class OrderByExpression {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
*
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class OrderByManager extends AbstractManager<ExpressionModifier> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @param <T> the type of elements in this list
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class PagedListImpl<T> extends ArrayList<T> implements PagedList<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0
* @since 1.0.0
*/
public class PaginatedCriteriaBuilderImpl<T> extends AbstractFullQueryBuilder<T, PaginatedCriteriaBuilder<T>, PaginatedCriteriaBuilderImpl<T>, PaginatedCriteriaBuilderImpl<T>, BaseFinalSetOperationBuilderImpl<T, ?, ?>> implements PaginatedCriteriaBuilder<T> {

Expand Down Expand Up @@ -392,7 +392,7 @@ private Map.Entry<TypedQuery<T>, KeysetExtractionObjectBuilder<T>> getObjectQuer
int keysetSize = orderByManager.getOrderByCount();

if (transformerObjectBuilder == null) {
objectBuilder = new KeysetExtractionObjectBuilder<T>(keysetSize, keysetMode);
objectBuilder = new KeysetExtractionObjectBuilder<T>(keysetSize, keysetMode, selectManager.getExpectedQueryResultType() != Object[].class);
} else {
objectBuilder = new DelegatingKeysetExtractionObjectBuilder<T>(transformerObjectBuilder, keysetSize, keysetMode);
}
Expand Down
Loading

0 comments on commit dbfe36f

Please sign in to comment.