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

    • Constructor Detail

      • QueryModelMapping

        protected QueryModelMapping​(@NotNull
                                    @NotNull String tableName,
                                    @NotNull
                                    @NotNull String defaultAliasName,
                                    @NotNull
                                    @NotNull Class<S> schemaType,
                                    @NotNull
                                    @NotNull Class<Q> queryType)
        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

      • addItemMapping

        public final void addItemMapping​(ItemName itemName,
                                         ItemSqlMapper itemMapper)
        Adds information how item (attribute) from schema type is mapped to query, especially for condition creating purposes.

        The ItemSqlMapper works as a factory for FilterProcessor that can process ObjectFilter related to the ItemName specified as the first parameter. It is not possible to use filter processor directly because at the time of mapping specification we don't have the actual query path representing the entity or the column. These paths are non-static properties of query class instances.

        The ItemSqlMapper also provides so called "primary mapping" to a column for ORDER BY part of the filter. But there can be additional column mappings specified as for some types (e.g. poly-strings) there may be other than 1-to-1 mapping.

        Construction of the ItemSqlMapper is typically simplified by static methods #mapper() provided on various *ItemFilterProcessor classes. This works as a "processor factory factory" and makes table mapping specification simpler.

        Parameters:
        itemName - item name from schema type (see F_* constants on schema types)
        itemMapper - mapper wrapping the information about column mappings working also as a factory for FilterProcessor
      • 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
      • path

        protected <A> Function<com.querydsl.core.types.EntityPath<?>,​com.querydsl.core.types.Path<?>> path​(Function<Q,​com.querydsl.core.types.Path<A>> rootToQueryItem)
        Lambda "wrapper" that helps with type inference when mapping paths from entity path. The returned types are ambiguous just as they are used in mapper() static methods on item filter processors.
      • path

        protected <OQ extends com.querydsl.core.types.EntityPath<OR>,​OR,​A> Function<com.querydsl.core.types.EntityPath<?>,​com.querydsl.core.types.Path<?>> path​(Class<OQ> queryType,
                                                                                                                                                                                  Function<OQ,​com.querydsl.core.types.Path<A>> entityToQueryItem)
        Lambda "wrapper" but this time with explicit query type (otherwise unused by the method) for paths not starting on the Q parameter used for this mapping instance.
      • joinOn

        protected <DQ extends com.querydsl.core.types.EntityPath<DR>,​DR> BiFunction<Q,​DQ,​com.querydsl.core.types.Predicate> joinOn​(BiFunction<Q,​DQ,​com.querydsl.core.types.Predicate> joinOnPredicateFunction)
        Helping lambda "wrapper" that helps with the type inference (namely the current Q type).
      • tableName

        public String tableName()
      • defaultAliasName

        public String defaultAliasName()
      • schemaType

        public Class<S> schemaType()
        This refers to midPoint schema, not DB schema.
      • queryType

        public Class<Q> queryType()
      • newAlias

        public Q newAlias​(String alias)
      • 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()
      • createTransformer

        public SqlTransformer<S,​Q,​R> createTransformer​(PrismContext prismContext,
                                                                   com.querydsl.sql.Configuration querydslConfiguration)
        Creates SqlTransformer of row bean to schema type, override if provided.
      • 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)