public MorphiaQuery(Morphia morphia, Datastore datastore, EntityCache cache, EntityPath<K> entityPath) { this(morphia, datastore, cache, entityPath.getType()); }
/** * Returns a {@link SpringDataMongodbQuery} for the given {@link EntityPath} querying the given collection. * * @param path must not be {@literal null} * @param collection must not be blank or {@literal null} * @return */ protected <T> SpringDataMongodbQuery<T> from(final EntityPath<T> path, String collection) { Assert.notNull(path, "EntityPath must not be null!"); Assert.hasText(collection, "Collection name must not be null or empty!"); return new SpringDataMongodbQuery<T>(template, path.getType(), collection); } }
/** * Returns a {@link SpringDataMongodbQuery} for the given {@link EntityPath}. The collection being queried is derived from the * entity metadata. * * @param path * @return */ protected <T> SpringDataMongodbQuery<T> from(final EntityPath<T> path) { Assert.notNull(path, "EntityPath must not be null!"); MongoPersistentEntity<?> entity = context.getRequiredPersistentEntity(path.getType()); return from(path, entity.getCollection()); }
protected static <E> PathBuilder<E> pathBuilderFor(EntityPath<E> path) { return new PathBuilder<>(path.getType(), path.getMetadata()); }
/** * Creates a new {@link QuerydslJpaPredicateExecutor} from the given domain class and {@link EntityManager} and uses * the given {@link EntityPathResolver} to translate the domain class into an {@link EntityPath}. * * @param entityInformation must not be {@literal null}. * @param entityManager must not be {@literal null}. * @param resolver must not be {@literal null}. * @param metadata maybe {@literal null}. */ public QuerydslJpaPredicateExecutor(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager, EntityPathResolver resolver, @Nullable CrudMethodMetadata metadata) { this.entityInformation = entityInformation; this.metadata = metadata; this.path = resolver.createPath(entityInformation.getJavaType()); this.querydsl = new Querydsl(entityManager, new PathBuilder<T>(path.getType(), path.getMetadata())); this.entityManager = entityManager; }
/** * Creates a new {@link QuerydslJpaRepository} from the given domain class and {@link EntityManager} and uses the * given {@link EntityPathResolver} to translate the domain class into an {@link EntityPath}. * * @param entityInformation must not be {@literal null}. * @param entityManager must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslJpaRepository(JpaEntityInformation<T, ID> entityInformation, EntityManager entityManager, EntityPathResolver resolver) { super(entityInformation, entityManager); this.path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<T>(path.getType(), path.getMetadata()); this.querydsl = new Querydsl(entityManager, builder); this.entityManager = entityManager; }
/** * Returns a {@link SpringDataMongodbQuery} for the given {@link EntityPath} querying the given collection. * * @param path must not be {@literal null} * @param collection must not be blank or {@literal null} * @return */ protected <T> SpringDataMongodbQuery<T> from(final EntityPath<T> path, String collection) { Assert.notNull(path, "EntityPath must not be null!"); Assert.hasText(collection, "Collection name must not be null or empty!"); return new SpringDataMongodbQuery<T>(template, path.getType(), collection); } }
/** * Returns a {@link SpringDataMongodbQuery} for the given {@link EntityPath}. The collection being queried is derived from the * entity metadata. * * @param path * @return */ protected <T> SpringDataMongodbQuery<T> from(final EntityPath<T> path) { Assert.notNull(path, "EntityPath must not be null!"); MongoPersistentEntity<?> entity = context.getRequiredPersistentEntity(path.getType()); return from(path, entity.getCollection()); }
/** * Creates a new {@link QuerydslMongoPredicateExecutor} for the given {@link MongoEntityInformation}, * {@link MongoOperations} and {@link EntityPathResolver}. * * @param entityInformation must not be {@literal null}. * @param mongoOperations must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslMongoPredicateExecutor(MongoEntityInformation<T, ?> entityInformation, MongoOperations mongoOperations, EntityPathResolver resolver) { Assert.notNull(resolver, "EntityPathResolver must not be null!"); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<T>(path.getType(), path.getMetadata()); this.entityInformation = entityInformation; this.mongoOperations = mongoOperations; }
/** * Creates a new {@link QuerydslLdapQuery}. * * @param ldapOperations must not be {@literal null}. * @param entityPath must not be {@literal null}. */ public QuerydslLdapQuery(LdapOperations ldapOperations, EntityPath<K> entityPath) { this(ldapOperations, entityPath.getType()); }
@Override public Class<? extends T> getType() { return entityPath.getType(); }
@SuppressWarnings("unchecked") @Override public Optional<RelationalTarget> resolve(QueryDslTarget expression, JPQLResolutionContext context) throws InvalidExpressionException { // validate expression.validate(); // use target entity class return Optional.of(RelationalTarget.of(JpaTarget.of(expression.getEntityPath().getType()))); }
/** * Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation}, * {@link KeyValueOperations} and {@link EntityPathResolver}. * * @param entityInformation must not be {@literal null}. * @param operations must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations, EntityPathResolver resolver) { super(entityInformation, operations); Assert.notNull(resolver, "EntityPathResolver must not be null!"); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<>(path.getType(), path.getMetadata()); }
/** * Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation}, * {@link KeyValueOperations} and {@link EntityPathResolver}. * * @param entityInformation must not be {@literal null}. * @param operations must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations, EntityPathResolver resolver) { super(entityInformation, operations); Assert.notNull(resolver, "EntityPathResolver must not be null!"); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<>(path.getType(), path.getMetadata()); }
@SuppressWarnings("unchecked") @Override public Optional<JpaEntity> resolve(QueryDslTarget expression, JPQLResolutionContext context) throws InvalidExpressionException { // validate expression.validate(); // use target entity class return Optional.of(JpaEntity.create(context.getEntityManagerFactory().getMetamodel(), expression.getEntityPath().getType())); }
public QDataTablesRepositoryImpl(JpaEntityInformation<T, ID> entityInformation, EntityManager entityManager, EntityPathResolver resolver) { super(entityInformation, entityManager); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<>(path.getType(), path.getMetadata()); }
/** * Creates a new {@link QuerydslJpaPredicateExecutor} from the given domain class and {@link EntityManager} and uses * the given {@link EntityPathResolver} to translate the domain class into an {@link EntityPath}. * * @param entityInformation must not be {@literal null}. * @param entityManager must not be {@literal null}. * @param resolver must not be {@literal null}. * @param metadata maybe {@literal null}. */ public QuerydslJpaPredicateExecutor(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager, EntityPathResolver resolver, @Nullable CrudMethodMetadata metadata) { this.entityInformation = entityInformation; this.metadata = metadata; this.path = resolver.createPath(entityInformation.getJavaType()); this.querydsl = new Querydsl(entityManager, new PathBuilder<T>(path.getType(), path.getMetadata())); this.entityManager = entityManager; }
public EntityRepositoryImpl(JpaEntityInformation<T, I> entityInformation, EntityManager entityManager, EntityPathResolver resolver) { super(entityInformation, entityManager, resolver); this.entityInformation = entityInformation; this.entityManager = entityManager; this.path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<T>(path.getType(), path.getMetadata()); this.querydsl = new Querydsl(entityManager, builder); }
/** * Creates a new {@link QuerydslJpaRepository} from the given domain class and {@link EntityManager} and uses the * given {@link EntityPathResolver} to translate the domain class into an {@link EntityPath}. * * @param entityInformation must not be {@literal null}. * @param entityManager must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslJpaRepository(JpaEntityInformation<T, ID> entityInformation, EntityManager entityManager, EntityPathResolver resolver) { super(entityInformation, entityManager); this.path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<T>(path.getType(), path.getMetadata()); this.querydsl = new Querydsl(entityManager, builder); this.entityManager = entityManager; }
@SuppressWarnings("unchecked") public static void orderBy(JPQLQuery<?> query, EntityPath<?> entity, List<String> order) { PathBuilder<?> builder = new PathBuilder(entity.getType(), entity.getMetadata()); Map<String, PathBuilder<?>> joins = Maps.newHashMap(); for (String entry : order) { String[] tokens = DOT.split(entry); if (tokens.length > 1) { String[] parent = new String[tokens.length - 1]; System.arraycopy(tokens, 0, parent, 0, tokens.length - 1); PathBuilder<?> parentAlias = join(query, builder, joins, StringUtils.join(parent, ".")); query.orderBy(parentAlias.getString(tokens[tokens.length - 1]).asc()); } else { query.orderBy(builder.getString(tokens[0]).asc()); } } }