org.springframework.data.repository.core.EntityMetadata Java Examples

The following examples show how to use org.springframework.data.repository.core.EntityMetadata. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSolrQuery.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
protected FacetPage<?> executeFind(Query query) {
	Assert.isInstanceOf(FacetQuery.class, query);

	EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation();
	return solrOperations.queryForFacetPage((FacetQuery) query, metadata.getJavaType());
}
 
Example #2
Source File: CosmosQueryMethod.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public EntityMetadata<?> getEntityInformation() {
    final Class<Object> domainType = (Class<Object>) getDomainClass();
    final CosmosEntityInformation entityInformation =
            new CosmosEntityInformation<Object, String>(domainType);

    this.metadata = new SimpleCosmosEntityMetadata<Object>(domainType, entityInformation);
    return this.metadata;
}
 
Example #3
Source File: ReactiveCosmosQueryMethod.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public EntityMetadata<?> getEntityInformation() {
    final Class<Object> domainType = (Class<Object>) getDomainClass();
    final CosmosEntityInformation entityInformation =
            new CosmosEntityInformation<Object, String>(domainType);

    this.metadata = new SimpleReactiveCosmosEntityMetadata<Object>(domainType, entityInformation);
    return this.metadata;
}
 
Example #4
Source File: ExpressionBasedStringQuery.java    From spring-data-ebean with Apache License 2.0 5 votes vote down vote up
/**
 * @param query,   the query expression potentially containing a SpEL expression. Must not be {@literal null}.}
 * @param metadata the {@link EntityMetadata} for the given entity. Must not be {@literal null}.
 * @param parser   Must not be {@literal null}.
 * @return
 */
private static String renderQueryIfExpressionOrReturnQuery(String query, EntityMetadata<?> metadata,
                                                           SpelExpressionParser parser) {

    Assert.notNull(query, "query must not be null!");
    Assert.notNull(metadata, "metadata must not be null!");
    Assert.notNull(parser, "parser must not be null!");

    if (!containsExpression(query)) {
        return query;
    }

    StandardEvaluationContext evalContext = new StandardEvaluationContext();
    evalContext.setVariable(ENTITY_NAME, metadata.getJavaType().getName());

    query = potentiallyQuoteExpressionsParameter(query);

    Expression expr = parser.parseExpression(query, ParserContext.TEMPLATE_EXPRESSION);

    String result = expr.getValue(evalContext, String.class);

    if (result == null) {
        return query;
    }

    return potentiallyUnquoteParameterExpressions(result);
}
 
Example #5
Source File: AbstractSolrQuery.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected Page<?> executeFind(Query query) {
	EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation();
	return solrOperations.queryForPage(query, metadata.getJavaType());
}
 
Example #6
Source File: AbstractSolrQuery.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected HighlightPage<?> executeFind(Query query) {
	Assert.isInstanceOf(HighlightQuery.class, query);

	EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation();
	return solrOperations.queryForHighlightPage((HighlightQuery) query, metadata.getJavaType());
}
 
Example #7
Source File: AbstractSolrQuery.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Override
public Object execute(Query query) {
	EntityMetadata<?> metadata = solrQueryMethod.getEntityInformation();
	return solrOperations.queryForObject(query, metadata.getJavaType());
}
 
Example #8
Source File: ExpressionBasedStringQuery.java    From spring-data-ebean with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link ExpressionBasedStringQuery} for the given query and {@link EntityMetadata}.
 *
 * @param query    must not be {@literal null} or empty.
 * @param metadata must not be {@literal null}.
 * @param parser   must not be {@literal null}.
 */
public ExpressionBasedStringQuery(String query, EntityMetadata<?> metadata, SpelExpressionParser parser) {
    super(renderQueryIfExpressionOrReturnQuery(query, metadata, parser));
}