Class HqlQueryInfo

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.utils.HqlQueryInfo

public class HqlQueryInfo extends Object
Represents information extracted from an HQL (Bibernate Query Language) query. Parses the SELECT, JOIN FETCH, JOIN, and WHERE clauses to provide details about the HQL query.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • SELECT_PATTERN

      private static final Pattern SELECT_PATTERN
      Regular expression pattern for extracting SELECT clause from an HQL query.
    • JOIN_FETCH_PATTERN

      private static final Pattern JOIN_FETCH_PATTERN
      Regular expression pattern for extracting JOIN FETCH clauses from an HQL query.
    • JOIN_PATTERN

      private static final Pattern JOIN_PATTERN
      Regular expression pattern for extracting JOIN clauses from an HQL query.
    • WHERE_PATTERN

      private static final Pattern WHERE_PATTERN
      Regular expression pattern for extracting WHERE clause from an HQL query.
    • DOT

      public static final String DOT
      Dot separator constant used in constructing entity aliases.
      See Also:
    • entityName

      private String entityName
    • entityAlias

      private String entityAlias
    • conditions

      private String conditions
    • joins

      private final List<String> joins
    • fetchJoins

      private final List<String> fetchJoins
    • entityClass

      private final Class<?> entityClass
  • Constructor Details

    • HqlQueryInfo

      public HqlQueryInfo(String hqlQuery, Class<?> entityClass)
      Constructs an instance of HqlQueryInfo by parsing the provided HQL query and associating it with a specified entity class.
      Parameters:
      hqlQuery - The HQL query to be parsed.
      entityClass - The entity class associated with the HQL query.
  • Method Details

    • setEntityName

      public void setEntityName(String entityName)
      Sets the entity name obtained from the SELECT clause.
      Parameters:
      entityName - The entity name.
    • setEntityAlias

      public void setEntityAlias(String entityAlias)
      Sets the entity alias obtained from the SELECT clause.
      Parameters:
      entityAlias - The entity alias.
    • setConditions

      public void setConditions(String conditions)
      Sets the conditions obtained from the WHERE clause.
      Parameters:
      conditions - The conditions.
    • addJoin

      public void addJoin(String join)
      Adds a JOIN clause to the list of joins.
      Parameters:
      join - The JOIN clause.
    • addFetchJoin

      public void addFetchJoin(String fetchJoin)
      Adds a JOIN FETCH clause to the list of fetch joins.
      Parameters:
      fetchJoin - The JOIN FETCH clause.
    • toNativeSql

      public String toNativeSql()
      Converts the HQL query information into native SQL format based on the associated entity class.
      Returns:
      The native SQL representation of the HQL query information.