Interface QueryProducer

    • Method Detail

      • createQuery

        <R> Query<R> createQuery​(String queryString,
                                 Class<R> resultClass)
        Create a typed Query instance for the given HQL query string.

        The returned Query may be executed by calling Query.getResultList() or Query.getSingleResult().

        Parameters:
        queryString - The HQL query
        resultClass - The type of the query result
        Returns:
        The Query instance for manipulation and execution
        See Also:
        EntityManager.createQuery(String,Class)
      • createQuery

        <R> Query<R> createQuery​(jakarta.persistence.criteria.CriteriaQuery<R> criteriaQuery)
        Create a Query for the given JPA CriteriaQuery.
      • createNativeQuery

        <R> NativeQuery<R> createNativeQuery​(String sqlString,
                                             Class<R> resultClass)
        Create a NativeQuery instance for the given native SQL query using implicit mapping to the specified Java type.

        If the given class is an entity class, this method is equivalent to createNativeQuery(sqlString).addEntity("alias1", resultClass).

        Parameters:
        sqlString - The native (SQL) query string
        resultClass - The Java entity type to map results to
        Returns:
        The NativeQuery instance for manipulation and execution
        See Also:
        EntityManager.createNativeQuery(String,Class)
      • createNativeQuery

        <R> NativeQuery<R> createNativeQuery​(String sqlString,
                                             Class<R> resultClass,
                                             String tableAlias)
        Create a NativeQuery instance for the given native SQL query using implicit mapping to the specified Java type.

        If the given class is an entity class, this method is equivalent to createNativeQuery(sqlString).addEntity(tableAlias, resultClass).

        Parameters:
        sqlString - Native (SQL) query string
        resultClass - The Java entity type to map results to
        tableAlias - The table alias for columns in the result set
        Returns:
        The NativeQuery instance for manipulation and execution
        See Also:
        EntityManager.createNativeQuery(String,Class)
      • createNativeQuery

        @Deprecated(since="6.0")
        NativeQuery createNativeQuery​(String sqlString,
                                      String resultSetMappingName)
        Create a NativeQuery instance for the given native SQL query using an explicit mapping to the specified Java type.

        The given result set mapping name must identify a mapping defined by a SqlResultSetMapping annotation.

        Parameters:
        sqlString - The native (SQL) query string
        resultSetMappingName - The explicit result mapping name
        Returns:
        The NativeQuery instance for manipulation and execution
        See Also:
        EntityManager.createNativeQuery(String,Class), SqlResultSetMapping
      • createNativeQuery

        <R> NativeQuery<R> createNativeQuery​(String sqlString,
                                             String resultSetMappingName,
                                             Class<R> resultClass)
        Create a NativeQuery instance for the given native SQL query using an explicit mapping to the specified Java type.

        The given result set mapping name must identify a mapping defined by a SqlResultSetMapping annotation.

        Parameters:
        sqlString - The native (SQL) query string
        resultSetMappingName - The explicit result mapping name
        Returns:
        The NativeQuery instance for manipulation and execution
        See Also:
        EntityManager.createNativeQuery(String,Class), SqlResultSetMapping
      • createSelectionQuery

        SelectionQuery<?> createSelectionQuery​(String hqlString)
        Create a SelectionQuery reference for the given HQL. Only valid for select queries
        Throws:
        IllegalSelectQueryException - if the given HQL query is an insert, update or delete query
        See Also:
        EntityManager.createQuery(String)
      • createSelectionQuery

        <R> SelectionQuery<R> createSelectionQuery​(String hqlString,
                                                   Class<R> resultType)
        Create a SelectionQuery reference for the given HQL. Only valid for select queries
        Throws:
        IllegalSelectQueryException - if the given HQL query is an insert, update or delete query
        See Also:
        EntityManager.createQuery(String)
      • createSelectionQuery

        <R> SelectionQuery<R> createSelectionQuery​(jakarta.persistence.criteria.CriteriaQuery<R> criteria)
        Create a SelectionQuery reference for the given Criteria.
        See Also:
        EntityManager.createQuery(CriteriaQuery)
      • createMutationQuery

        MutationQuery createMutationQuery​(String hqlString)
        Create a MutationQuery reference for the given HQL insert, update, or delete statement.
        Throws:
        IllegalMutationQueryException - if the given HQL query is a select query
      • createMutationQuery

        MutationQuery createMutationQuery​(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
        Create a MutationQuery from the given update criteria tree
      • createMutationQuery

        MutationQuery createMutationQuery​(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
        Create a MutationQuery from the given delete criteria tree
      • createNativeMutationQuery

        MutationQuery createNativeMutationQuery​(String sqlString)
        Create a NativeQuery instance for the given native SQL statement.
        Parameters:
        sqlString - a native SQL statement string
        Returns:
        The NativeQuery instance for manipulation and execution
      • createNamedQuery

        <R> Query<R> createNamedQuery​(String name,
                                      Class<R> resultClass)
        Create a typed Query instance for the given named query. The named query might be defined in HQL or in native SQL.
        Parameters:
        name - the name of a query defined in metadata
        resultClass - the type of the query result
        Returns:
        The Query instance for manipulation and execution
        Throws:
        IllegalArgumentException - if a query has not been defined with the given name or if the query string is found to be invalid or if the query result is found to not be assignable to the specified type
        See Also:
        EntityManager.createNamedQuery(String,Class)