Class QueryTableMapping<S,​Q extends FlexibleRelationalPathBase<R>,​R>

    • Constructor Detail

      • QueryTableMapping

        protected QueryTableMapping​(@NotNull
                                    @NotNull String tableName,
                                    @NotNull
                                    @NotNull String defaultAliasName,
                                    @NotNull
                                    @NotNull Class<S> schemaType,
                                    @NotNull
                                    @NotNull Class<Q> queryType,
                                    @NotNull
                                    @NotNull SqlRepoContext repositoryContext)
        Creates metamodel for the table described by designated type (Q-class) related to schema type. Allows registration of any number of columns - typically used for static properties (non-extensions).
        Parameters:
        tableName - database table name
        defaultAliasName - default alias name, some short abbreviation, must be unique across mapped types
    • Method Detail

      • stringMapper

        protected ItemSqlMapper<Q,​R> stringMapper​(Function<Q,​com.querydsl.core.types.dsl.StringPath> rootToQueryItem)
        Returns the mapper creating the string filter processor from context.
      • integerMapper

        public ItemSqlMapper<Q,​R> integerMapper​(Function<Q,​com.querydsl.core.types.dsl.NumberPath<Integer>> rootToQueryItem)
        Returns the mapper creating the integer filter processor from context.
      • longMapper

        public ItemSqlMapper<Q,​R> longMapper​(Function<Q,​com.querydsl.core.types.dsl.NumberPath<Long>> rootToQueryItem)
        Returns the mapper creating the long filter processor from context.
      • booleanMapper

        protected ItemSqlMapper<Q,​R> booleanMapper​(Function<Q,​com.querydsl.core.types.dsl.BooleanPath> rootToQueryItem)
        Returns the mapper creating the boolean filter processor from context.
      • uuidMapper

        protected ItemSqlMapper<Q,​R> uuidMapper​(Function<Q,​UuidPath> rootToQueryItem)
        Returns the mapper creating the OID (UUID) filter processor from context.
      • timestampMapper

        protected <T extends Comparable<T>> ItemSqlMapper<Q,​R> timestampMapper​(Function<Q,​com.querydsl.core.types.dsl.DateTimePath<T>> rootToQueryItem)
        Returns the mapper function creating the timestamp filter processor from context.
        Type Parameters:
        T - actual data type of the query path storing the timestamp
      • polyStringMapper

        protected ItemSqlMapper<Q,​R> polyStringMapper​(Function<Q,​com.querydsl.core.types.dsl.StringPath> origMapping,
                                                            Function<Q,​com.querydsl.core.types.dsl.StringPath> normMapping)
        Returns the mapper creating the string filter processor from context.
      • addDetailFetchMapper

        public final void addDetailFetchMapper​(ItemName itemName,
                                               SqlDetailFetchMapper<R,​?,​?,​?> detailFetchMapper)
        Fetcher/mappers for detail tables take care of loading to-many details related to this mapped entity (master). One fetcher per detail type/table is registered under the related item name.
        Parameters:
        itemName - item name from schema type that is mapped to detail table in the repository
        detailFetchMapper - fetcher-mapper that handles loading of details
        See Also:
        SqlDetailFetchMapper
      • joinOn

        protected <TQ extends FlexibleRelationalPathBase<TR>,​TR> BiFunction<Q,​TQ,​com.querydsl.core.types.Predicate> joinOn​(BiFunction<Q,​TQ,​com.querydsl.core.types.Predicate> joinOnPredicateFunction)
        Lambda "wrapper" that helps with the type inference (namely the current Q type). Returned bi-function returns ON condition predicate for two entity paths.
        Type Parameters:
        TQ - query type for the JOINed (target) table
        TR - row type related to the QueryTableMapping
      • tableName

        public String tableName()
      • defaultAliasName

        public String defaultAliasName()
      • newAlias

        public Q newAlias​(String alias)
        Creates new alias (entity path instance) with a defined name. You can also use defaultAlias() if one alias in a query is enough. Entity path instance returned by this call is already enhanced by extension columns.
      • newAliasInstance

        protected abstract Q newAliasInstance​(String alias)
        Method returning new instance of EntityPath - to be implemented by sub-mapping. This will create entity path without any extension columns, see newAlias(java.lang.String) for that.
      • defaultAlias

        public Q defaultAlias()
        Returns default alias - use only once per query, e.g. not for two different joins. Also, don't cache it yourself, always use this method which ensures that the alias has all the extension columns configured properly.
      • addExtensionColumn

        public void addExtensionColumn​(String propertyName,
                                       com.querydsl.sql.ColumnMetadata columnMetadata)
        Registers extension columns. At this moment all are treated as strings.
      • getExtensionColumns

        public Map<String,​com.querydsl.sql.ColumnMetadata> getExtensionColumns()
      • selectExpressionsWithCustomColumns

        @NotNull
        public @NotNull com.querydsl.core.types.Path<?>[] selectExpressionsWithCustomColumns​(Q entity)
      • newRowObject

        public R newRowObject()
      • toSchemaObject

        public abstract S toSchemaObject​(R row)
                                  throws SchemaException
        Transforms row of QueryTableMapping type to schema type QueryTableMapping. If pre-generated bean is used as row it does not include extension (dynamic) columns, which is OK if extension columns are used only for query and their information is still contained in the object somehow else (e.g. full object LOB). Alternative would be dynamically generated list of select expressions and transforming row to M object directly from Tuple.
        Throws:
        SchemaException
      • createRowTransformer

        public ResultListRowTransformer<S,​Q,​R> createRowTransformer​(SqlQueryContext<S,​Q,​R> sqlQueryContext,
                                                                                JdbcSession jdbcSession)
        Similarly, transformation to midPoint objects allows for state using ResultListRowTransformer instead of is done in one-by-one manner, it is not done by the mapping (which is otherwise stateless), but the mapping creates transformer , there is also room for a stateful object