protected static <E> PathBuilder<E> pathBuilderFor(EntityPath<E> path) { return new PathBuilder<>(path.getType(), path.getMetadata()); }
public MorphiaQuery(Morphia morphia, Datastore datastore, EntityCache cache, EntityPath<K> entityPath) { this(morphia, datastore, cache, entityPath.getType()); }
private <P extends Path<?>> P addMetadataOf(P newPath, Path<?> path) { if (path.getMetadata().getParent() instanceof EntityPath) { EntityPath<?> parent = (EntityPath<?>) path.getMetadata().getParent(); if (parent.getMetadata(path) != null) { propertyMetadata.putIfAbsent(newPath, parent.getMetadata(path)); } } return newPath; }
/** * 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); } }
@Override public String getName() { return entityPath.getMetadata().getName(); }
/** * 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}. 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()); }
private <P extends Path<?>> P addMetadataOf(P newPath, Path<?> path) { if (path.getMetadata().getParent() instanceof EntityPath) { EntityPath<?> parent = (EntityPath<?>) path.getMetadata().getParent(); if (parent.getMetadata(path) != null) { propertyMetadata.putIfAbsent(newPath, parent.getMetadata(path)); } } return newPath; }
/** * 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; }
/** * 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 this path's column metadata if present. Otherwise returns default * metadata where the column name is equal to the path's name. */ public static ColumnMetadata getColumnMetadata(Path<?> path) { Path<?> parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { Object columnMetadata = ((EntityPath<?>) parent).getMetadata(path); if (columnMetadata instanceof ColumnMetadata) { return (ColumnMetadata) columnMetadata; } } return ColumnMetadata.named(path.getMetadata().getName()); }
/** * 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; }
/** * 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()); }
/** * Extract the column name for the given path, returns the path name, if no ColumnMetadata is attached * * @param path patch * @return column name or path name */ public static String getName(Path<?> path) { Path<?> parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { Object columnMetadata = ((EntityPath<?>) parent).getMetadata(path); if (columnMetadata instanceof ColumnMetadata) { return ((ColumnMetadata) columnMetadata).getName(); } } return path.getMetadata().getName(); }
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 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()); }
/** * 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()); }
@Override public Class<? extends T> getType() { return entityPath.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()); }
@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()))); }