Package org.cyclos.impl.sql.postgresql
Class NativeQuery<Q extends QueryParameters,E extends SimpleEntity,P>
- java.lang.Object
-
- org.cyclos.impl.sql.postgresql.NativeQuery<Q,E,P>
-
- Direct Known Subclasses:
AbstractUserNativeQuery,AdvertisementsNativeQuery,ContactsNativeQuery,RecordsNativeQuery
public abstract class NativeQuery<Q extends QueryParameters,E extends SimpleEntity,P> extends Object
A native query, executed in Postgresql via Querydsl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classNativeQuery.BaseProjectionBase class for projections in native queriesprotected static classNativeQuery.JpaQueryResultprotected static interfaceNativeQuery.SQLQueryAction<T>Action executed with an initialized query
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationContextapplicationContextprotected BeanHandlerbeanHandlerprotected ConfigurationHandlerconfigurationHandlerprotected ConversionHandlerconversionHandlerprotected CustomFieldValueHandlercustomFieldValueHandlerprotected Class<E>entityTypeprotected GroupsHandlergroupsHandlerprotected JdbcTemplatejdbcTemplateprotected Qparamsprotected PhoneServiceLocalphoneServiceprotected ProfileFieldHandlerprofileFieldHandlerprotected Class<P>projectionTypeprotected RawEntityManagerHandlerrawEntityManagerHandlerprotected TranslationHandlertranslationHandlerprotected UserServiceLocaluserService
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <FV extends SBaseFieldValues<FV>,EV extends SBaseEnumValues<?>>
voidaddOrderBy(Class<FV> fvType, Class<EV> evType, com.querydsl.sql.SQLQuery<?> query, CustomField<?,?,?> customField, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, boolean descending)Adds an order by condition for a given custom field valueprotected Pair<TsVectorExpression,com.querydsl.core.BooleanBuilder>appendUserProfileFieldKeywords(ProfileFieldSearchContext context, String keywords, TsVectorExpression tsvectors, SUsers u, boolean myBrokered)Applies the filters for user profile fields.static com.querydsl.core.types.Predicateapply(UserProductsQueryResult r, SUsers u)protected voidapplyFullTextFilter(com.querydsl.sql.SQLQuery<?> query, TsVectorExpression tsvectors, STsQuery q, com.querydsl.core.BooleanBuilder keywordsCondition)protected Collection<STsQuery>applyUserProfileFieldFilters(ProfileFieldSearchContext context, com.querydsl.sql.SQLQuery<?> query, SUsers u, boolean myBrokered, Set<BaseValueForSearchDTO> profileFieldValues, SAddresses a)Applies the filters for user profile fields.intcount()Returns the record count for the current queryprotected NativeQuery.JpaQueryResultcreateJpaQuery(com.querydsl.core.types.Expression<?> projection, Integer firstResult, Integer maxResults)protected NativeQuery.JpaQueryResultcreateJpaQueryForEntities(Integer firstResult, Integer maxResults)protected <R> com.mysema.commons.lang.CloseableIterator<R>doIterate(NativeQuery.JpaQueryResult result)protected <R> RdoSingleResult(NativeQuery.JpaQueryResult result)protected com.querydsl.sql.SQLQuery<?>ensureQuery()protected <EV extends SBaseEnumValues<?>>
EVenumValue(CustomField<?,?,?> customField, Class<EV> evType)Returns the alias for enum values of the given custom fieldprotected <FV extends SBaseFieldValues<FV>>
FVfieldValue(CustomField<?,?,?> customField, Class<FV> fvType)protected voidfilterByDatePeriod(com.querydsl.core.support.QueryBase<?> query, DatePeriodDTO period, com.querydsl.core.types.dsl.DateTimeExpression<Date> path)Adds a query expression in a custom query (or subquery)protected voidfilterByDatePeriod(DatePeriodDTO period, com.querydsl.core.types.dsl.DateTimeExpression<Date> path)Adds a query expressionprotected <FV extends SBaseFieldValues<FV>,EV extends SBaseEnumValues<?>>
Pair<com.querydsl.core.BooleanBuilder,STsQuery>getCustomFieldQueryCondition(Class<FV> fvType, Class<EV> evType, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch, boolean canViewHidden)Returns the condition for a custom field filter joining if necessary, plus an optional extraSTsQuerythat needs to be added to the query from clauseprotected <T extends SBaseFieldValues<T>>
Pair<com.querydsl.core.BooleanBuilder,STsQuery>getCustomFieldQueryCondition(Class<T> fvType, Class<? extends SBaseEnumValues<?>> evType, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch)protected Map<CustomField<?,?,?>,SBaseFieldValues<?>>getFieldValues()protected FormatterImplgetFormatter()protected org.apache.logging.log4j.LoggergetLogger()protected abstract com.querydsl.sql.RelationalPath<?>getMainEntityAlias()Must be implemented in order to return the alias for the main entity in the queryprotected abstract com.querydsl.core.types.Expression<P>getProjection(com.querydsl.sql.SQLQuery<?> query, Integer totalCount)Must be implemented in order to return projection for results in the query, given the total record countcom.querydsl.sql.SQLQuery<?>getQuery()protected SessionDatagetSessionData()protected abstract List<com.querydsl.core.types.Expression<?>>initializeQuery(com.querydsl.sql.SQLQuery<?> query)Initializes the query, returning additional from expressions that should be applied after all otherscom.mysema.commons.lang.CloseableIterator<E>iterateEntities()Returns an iterator with JPA entities for the current querycom.mysema.commons.lang.CloseableIterator<Long>iterateIds()Returns an iterator with entity ids for the current querycom.mysema.commons.lang.CloseableIterator<P>iterateResults()protected <T extends SBaseFieldValues<T>>
Tjoin(Class<T> fvType, Class<? extends SBaseEnumValues<?>> evType, com.querydsl.sql.SQLQuery<?> query, CustomField<?,?,?> customField, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath)Adds a join to a custom field value tablePage<E>pageEntities()Returns a page with entities for the current queryPage<P>pageResults()protected voidresetQuery()SQLUserVisibilityAppliervisibility(com.querydsl.core.types.dsl.NumberPath<Long> userId, com.querydsl.core.types.dsl.NumberPath<Long> groupId)Returns a visibility applier to add the user visibility rules for the given user id and group id paths.
-
-
-
Field Detail
-
entityType
protected Class<E extends SimpleEntity> entityType
-
params
protected Q extends QueryParameters params
-
applicationContext
@Autowired protected ApplicationContext applicationContext
-
rawEntityManagerHandler
@Autowired protected RawEntityManagerHandler rawEntityManagerHandler
-
conversionHandler
@Autowired protected ConversionHandler conversionHandler
-
groupsHandler
@Autowired protected GroupsHandler groupsHandler
-
configurationHandler
@Autowired protected ConfigurationHandler configurationHandler
-
beanHandler
@Autowired protected BeanHandler beanHandler
-
profileFieldHandler
@Autowired protected ProfileFieldHandler profileFieldHandler
-
phoneService
@Autowired protected PhoneServiceLocal phoneService
-
translationHandler
@Autowired protected TranslationHandler translationHandler
-
userService
@Autowired protected UserServiceLocal userService
-
customFieldValueHandler
@Autowired protected CustomFieldValueHandler customFieldValueHandler
-
jdbcTemplate
@Autowired protected JdbcTemplate jdbcTemplate
-
-
Method Detail
-
apply
public static com.querydsl.core.types.Predicate apply(UserProductsQueryResult r, SUsers u)
-
count
public int count()
Returns the record count for the current query
-
getQuery
public com.querydsl.sql.SQLQuery<?> getQuery()
-
iterateEntities
public com.mysema.commons.lang.CloseableIterator<E> iterateEntities()
Returns an iterator with JPA entities for the current query
-
iterateIds
public com.mysema.commons.lang.CloseableIterator<Long> iterateIds()
Returns an iterator with entity ids for the current query
-
iterateResults
public com.mysema.commons.lang.CloseableIterator<P> iterateResults()
-
visibility
public SQLUserVisibilityApplier visibility(com.querydsl.core.types.dsl.NumberPath<Long> userId, com.querydsl.core.types.dsl.NumberPath<Long> groupId)
Returns a visibility applier to add the user visibility rules for the given user id and group id paths.
-
addOrderBy
protected <FV extends SBaseFieldValues<FV>,EV extends SBaseEnumValues<?>> void addOrderBy(Class<FV> fvType, Class<EV> evType, com.querydsl.sql.SQLQuery<?> query, CustomField<?,?,?> customField, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, boolean descending)
Adds an order by condition for a given custom field value
-
appendUserProfileFieldKeywords
protected Pair<TsVectorExpression,com.querydsl.core.BooleanBuilder> appendUserProfileFieldKeywords(ProfileFieldSearchContext context, String keywords, TsVectorExpression tsvectors, SUsers u, boolean myBrokered)
Applies the filters for user profile fields. Not as keywords, but as filters.
-
applyFullTextFilter
protected void applyFullTextFilter(com.querydsl.sql.SQLQuery<?> query, TsVectorExpression tsvectors, STsQuery q, com.querydsl.core.BooleanBuilder keywordsCondition)
-
applyUserProfileFieldFilters
protected Collection<STsQuery> applyUserProfileFieldFilters(ProfileFieldSearchContext context, com.querydsl.sql.SQLQuery<?> query, SUsers u, boolean myBrokered, Set<BaseValueForSearchDTO> profileFieldValues, SAddresses a)
Applies the filters for user profile fields. Not as keywords, but as filters. Returns a collection ofSTsQuerythat should be added to the query from.
-
createJpaQuery
protected NativeQuery.JpaQueryResult createJpaQuery(com.querydsl.core.types.Expression<?> projection, Integer firstResult, Integer maxResults)
-
createJpaQueryForEntities
protected NativeQuery.JpaQueryResult createJpaQueryForEntities(Integer firstResult, Integer maxResults)
-
doIterate
protected <R> com.mysema.commons.lang.CloseableIterator<R> doIterate(NativeQuery.JpaQueryResult result)
-
doSingleResult
protected <R> R doSingleResult(NativeQuery.JpaQueryResult result)
-
ensureQuery
protected com.querydsl.sql.SQLQuery<?> ensureQuery()
-
enumValue
protected <EV extends SBaseEnumValues<?>> EV enumValue(CustomField<?,?,?> customField, Class<EV> evType)
Returns the alias for enum values of the given custom field
-
fieldValue
protected <FV extends SBaseFieldValues<FV>> FV fieldValue(CustomField<?,?,?> customField, Class<FV> fvType)
-
filterByDatePeriod
protected void filterByDatePeriod(DatePeriodDTO period, com.querydsl.core.types.dsl.DateTimeExpression<Date> path)
Adds a query expression
-
filterByDatePeriod
protected void filterByDatePeriod(com.querydsl.core.support.QueryBase<?> query, DatePeriodDTO period, com.querydsl.core.types.dsl.DateTimeExpression<Date> path)Adds a query expression in a custom query (or subquery)
-
getCustomFieldQueryCondition
protected <FV extends SBaseFieldValues<FV>,EV extends SBaseEnumValues<?>> Pair<com.querydsl.core.BooleanBuilder,STsQuery> getCustomFieldQueryCondition(Class<FV> fvType, Class<EV> evType, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch, boolean canViewHidden)
Returns the condition for a custom field filter joining if necessary, plus an optional extraSTsQuerythat needs to be added to the query from clause
-
getCustomFieldQueryCondition
protected <T extends SBaseFieldValues<T>> Pair<com.querydsl.core.BooleanBuilder,STsQuery> getCustomFieldQueryCondition(Class<T> fvType, Class<? extends SBaseEnumValues<?>> evType, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch)
-
getFieldValues
protected Map<CustomField<?,?,?>,SBaseFieldValues<?>> getFieldValues()
-
getFormatter
protected FormatterImpl getFormatter()
-
getLogger
protected org.apache.logging.log4j.Logger getLogger()
-
getMainEntityAlias
protected abstract com.querydsl.sql.RelationalPath<?> getMainEntityAlias()
Must be implemented in order to return the alias for the main entity in the query
-
getProjection
protected abstract com.querydsl.core.types.Expression<P> getProjection(com.querydsl.sql.SQLQuery<?> query, Integer totalCount)
Must be implemented in order to return projection for results in the query, given the total record count
-
getSessionData
protected SessionData getSessionData()
-
initializeQuery
protected abstract List<com.querydsl.core.types.Expression<?>> initializeQuery(com.querydsl.sql.SQLQuery<?> query)
Initializes the query, returning additional from expressions that should be applied after all others
-
join
protected <T extends SBaseFieldValues<T>> T join(Class<T> fvType, Class<? extends SBaseEnumValues<?>> evType, com.querydsl.sql.SQLQuery<?> query, CustomField<?,?,?> customField, com.querydsl.core.types.dsl.NumberPath<Long> ownerIdPath)
Adds a join to a custom field value table
-
resetQuery
protected void resetQuery()
-
-