Class YqlStatement<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,RESULT>
java.lang.Object
tech.ydb.yoj.repository.ydb.statement.YqlStatement<PARAMS,ENTITY,RESULT>
- All Implemented Interfaces:
Statement<PARAMS,RESULT>
- Direct Known Subclasses:
FindAllYqlStatement,FindRangeStatement,MultipleVarsYqlStatement,PredicateStatement,UpdateInStatement,YqlStatement.Simple
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classYqlStatement.Simple<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> Nested classes/interfaces inherited from interface tech.ydb.yoj.repository.ydb.statement.Statement
Statement.QueryType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Collector<com.yandex.ydb.ValueProtos.Value.Builder,com.yandex.ydb.ValueProtos.Value.Builder, com.yandex.ydb.ValueProtos.Value.Builder> protected static final YqlOrderByprotected final tech.ydb.yoj.databind.schema.Schema<RESULT>protected final ResultSetReader<RESULT>protected final tech.ydb.yoj.repository.db.EntitySchema<ENTITY>protected final String -
Constructor Summary
ConstructorsConstructorDescriptionYqlStatement(@NonNull tech.ydb.yoj.repository.db.EntitySchema<ENTITY> schema, @NonNull tech.ydb.yoj.databind.schema.Schema<RESULT> resultSchema) YqlStatement(@NonNull tech.ydb.yoj.repository.db.EntitySchema<ENTITY> schema, @NonNull tech.ydb.yoj.databind.schema.Schema<RESULT> resultSchema, @NonNull String tableName) -
Method Summary
Modifier and TypeMethodDescriptionstatic <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<Collection<? extends YqlStatementPart<?>>,Count> count(Class<ENTITY> entityType, Collection<? extends YqlStatementPart<?>> parts) protected com.yandex.ydb.ValueProtos.TypedValuecreateTQueryParameter(YqlType type, Object o, boolean optional) protected Stringstatic <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> booleanprotected Stringstatic <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, VIEW extends tech.ydb.yoj.repository.db.Table.View>
Statement<PARAMS,VIEW> static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View>
Statement<Collection<? extends YqlStatementPart<?>>,VIEW> find(Class<ENTITY> type, Class<VIEW> viewType, boolean distinct, Collection<? extends YqlStatementPart<?>> parts) static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View>
Statement<Collection<? extends YqlStatementPart<?>>,VIEW> find(Class<ENTITY> type, Class<VIEW> viewType, Collection<? extends YqlStatementPart<?>> parts) static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<Collection<? extends YqlStatementPart<?>>,ENTITY> find(Class<ENTITY> type, Collection<? extends YqlStatementPart<?>> parts) static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, VIEW extends tech.ydb.yoj.repository.db.Table.View>
Statement<PARAMS,VIEW> static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<Collection<? extends YqlStatementPart<?>>,ID> findIds(Class<ENTITY> type, Collection<? extends YqlStatementPart<?>> parts) static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<tech.ydb.yoj.repository.db.Range<ID>,ID> static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<PARAMS,ID> findIdsIn(Class<ENTITY> type, Iterable<ID> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, VIEW extends tech.ydb.yoj.repository.db.Table.View>
Statement<PARAMS,VIEW> findIn(Class<ENTITY> type, Class<VIEW> viewType, Iterable<? extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, VIEW extends tech.ydb.yoj.repository.db.Table.View, K>
Statement<PARAMS,VIEW> findIn(Class<ENTITY> type, Class<VIEW> viewType, String indexName, Iterable<K> keys, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> findIn(Class<ENTITY> type, Iterable<? extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, K>
Statement<PARAMS,ENTITY> findIn(Class<ENTITY> type, String indexName, Iterable<K> keys, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View, ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<tech.ydb.yoj.repository.db.Range<ID>,VIEW> static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<tech.ydb.yoj.repository.db.Range<ID>,ENTITY> getDeclaration(String name, String type) protected Collection<YqlStatementParam>@NonNull Stringprotected com.yandex.ydb.ValueProtos.Type.BuildergetYqlType(YqlType yqlType, boolean optional) protected com.yandex.ydb.ValueProtos.Value.BuildergetYqlValue(YqlType type, Object value) inthashCode()static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> booleanTells whether the statement should be prepared, that is, parsed once and then cached for subsequent queries during the same session.
Prepared statements offer better query performance, but consume additional memory.protected static Stream<? extends YqlStatementPart<?>>mergeParts(Stream<? extends YqlStatementPart<?>> origParts) protected Stringprotected StringoutNames()protected static YqlPredicatepredicateFrom(Collection<? extends YqlStatementPart<?>> parts) readResult(List<com.yandex.ydb.ValueProtos.Column> columns, com.yandex.ydb.ValueProtos.Value value) Converts YDB result set into the query result.protected StringresolveParamNames(String yql) Resolves?placeholders to respective statement parameters' names, and{entity.java.field}placeholders to DB field names.static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>>
Statement<PARAMS,ENTITY> voidstoreToCache(PARAMS params, List<RESULT> result, tech.ydb.yoj.repository.db.cache.RepositoryCache cache) Writes the query result to first-level cache.protected StringtoQueryParameters(PARAMS params) Returns the query's parameter values as YDB protobuf structures.toString()static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>>
Statement<UpdateModel.ById<ID>,?> update(Class<ENTITY> type, UpdateModel.ById<ID> model) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface tech.ydb.yoj.repository.ydb.statement.Statement
getQuery, getQueryType, readFromCache, toDebugString
-
Field Details
-
itemsCollector
protected static final Collector<com.yandex.ydb.ValueProtos.Value.Builder,com.yandex.ydb.ValueProtos.Value.Builder, itemsCollectorcom.yandex.ydb.ValueProtos.Value.Builder> -
ORDER_BY_ID_ASCENDING
-
schema
-
resultSchema
-
resultSetReader
-
tableName
-
-
Constructor Details
-
YqlStatement
-
YqlStatement
-
-
Method Details
-
insert
-
update
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> Statement<UpdateModel.ById<ID>,?> update(Class<ENTITY> type, UpdateModel.ById<ID> model) -
save
-
find
-
find
-
findRange
-
findRange
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View, Statement<tech.ydb.yoj.repository.db.Range<ID>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> VIEW> findRange(Class<ENTITY> type, Class<VIEW> viewType, tech.ydb.yoj.repository.db.Range<ID> range) -
findIdsIn
public static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, Statement<PARAMS,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> ID> findIdsIn(Class<ENTITY> type, Iterable<ID> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) -
findIn
public static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> Statement<PARAMS,ENTITY> findIn(Class<ENTITY> type, Iterable<? extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) -
findIn
public static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, Statement<PARAMS,VIEW extends tech.ydb.yoj.repository.db.Table.View> VIEW> findIn(Class<ENTITY> type, Class<VIEW> viewType, Iterable<? extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> ids, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) -
findIn
public static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, Statement<PARAMS,K> ENTITY> findIn(Class<ENTITY> type, String indexName, Iterable<K> keys, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) -
findIn
public static <PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>, Statement<PARAMS,VIEW extends tech.ydb.yoj.repository.db.Table.View, K> VIEW> findIn(Class<ENTITY> type, Class<VIEW> viewType, String indexName, Iterable<K> keys, tech.ydb.yoj.databind.expression.FilterExpression<ENTITY> filter, tech.ydb.yoj.databind.expression.OrderExpression<ENTITY> orderBy, Integer limit) -
findAll
-
findAll
-
find
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> Statement<Collection<? extends YqlStatementPart<?>>,ENTITY> find(Class<ENTITY> type, Collection<? extends YqlStatementPart<?>> parts) -
find
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View> Statement<Collection<? extends YqlStatementPart<?>>,VIEW> find(Class<ENTITY> type, Class<VIEW> viewType, Collection<? extends YqlStatementPart<?>> parts) -
find
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,VIEW extends tech.ydb.yoj.repository.db.Table.View> Statement<Collection<? extends YqlStatementPart<?>>,VIEW> find(Class<ENTITY> type, Class<VIEW> viewType, boolean distinct, Collection<? extends YqlStatementPart<?>> parts) -
findIds
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>,ID extends tech.ydb.yoj.repository.db.Entity.Id<ENTITY>> Statement<Collection<? extends YqlStatementPart<?>>,ID> findIds(Class<ENTITY> type, Collection<? extends YqlStatementPart<?>> parts) -
findIds
-
storeToCache
public void storeToCache(PARAMS params, List<RESULT> result, tech.ydb.yoj.repository.db.cache.RepositoryCache cache) Description copied from interface:StatementWrites the query result to first-level cache.- Specified by:
storeToCachein interfaceStatement<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> - Parameters:
params- parameter values Might benulldepending on the statement type, e.g. for DELETE statements.result- result to save; ifnull, nothing will be saved to cachecache- first-level cache
-
getDeclaration
-
count
public static <ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> Statement<Collection<? extends YqlStatementPart<?>>,Count> count(Class<ENTITY> entityType, Collection<? extends YqlStatementPart<?>> parts) -
predicateFrom
-
mergeParts
protected static Stream<? extends YqlStatementPart<?>> mergeParts(Stream<? extends YqlStatementPart<?>> origParts) -
deleteAll
-
delete
-
isPreparable
public boolean isPreparable()Description copied from interface:StatementTells whether the statement should be prepared, that is, parsed once and then cached for subsequent queries during the same session.
Prepared statements offer better query performance, but consume additional memory.You should not blindly prepare all statements, especially non-parameterized ones; so by default this method returns
false.- Specified by:
isPreparablein interfaceStatement<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> - Returns:
trueif the statement should be prepared;falseotherwise
-
toQueryParameters
Description copied from interface:StatementReturns the query's parameter values as YDB protobuf structures.- Specified by:
toQueryParametersin interfaceStatement<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> - Parameters:
params- parameter values Might benulldepending on the statement type, e.g. for DELETE statements.- Returns:
- map: parameter name -> value as protobuf
-
createTQueryParameter
-
getYqlType
-
getYqlValue
-
readResult
public RESULT readResult(List<com.yandex.ydb.ValueProtos.Column> columns, com.yandex.ydb.ValueProtos.Value value) Description copied from interface:StatementConverts YDB result set into the query result.- Specified by:
readResultin interfaceStatement<PARAMS,ENTITY extends tech.ydb.yoj.repository.db.Entity<ENTITY>> - Parameters:
columns- result set as a YDB protobuf structurevalue- result set as a YDB protobuf structure- Returns:
- query result
-
toString
-
equals
-
hashCode
public int hashCode() -
getInSchemaType
-
getTableName
-
getParams
-
declarations
-
outNames
-
nameEqVars
-
table
-
escape
-
resolveParamNames
Resolves?placeholders to respective statement parameters' names, and{entity.java.field}placeholders to DB field names.- Parameters:
yql- YQL with parameter and field name placeholders (?and{field.name}, respectively)- Returns:
- YQL with real parameter names
-