Class LegacyNamedObjectParser

java.lang.Object
persist.lint.legacy.LegacyNamedObjectParser
All Implemented Interfaces:
AutoCloseable, NamedObjectParser, PersistenceLinter

public class LegacyNamedObjectParser extends Object implements NamedObjectParser
NamedObjectParser implementation for the legacy javax.persistence namespace.

This parser uses Hibernate 5 to compile JPQL query strings through the AST-based QueryTranslatorFactory. The compilation verifies HQL grammar, entity mappings, and property paths entirely offline — no live database connection is required.

Stored procedure declarations are validated by recording the procedure name and its parameter names into a NamedObjectDescriptor.

Instances are created through the from(List) factory method. This class implements AutoCloseable; closing an instance releases the underlying Hibernate SessionFactory and ServiceRegistry. Always use try-with-resources.

Since:
2.0.0
See Also:
  • Method Details

    • from

      public static LegacyNamedObjectParser from(List<String> discoveredClassNames)
      Creates a new LegacyNamedObjectParser configured with the supplied entity class names.
      Parameters:
      discoveredClassNames - fully qualified names of JPA entity classes
      Returns:
      a parser ready to validate named queries and stored procedures; the caller is responsible for closing it when finished
    • parseQuery

      public NamedObjectDescriptor parseQuery(String name, String queryString)
      Parses and semantically validates the given JPQL query string.

      If the query contains syntax errors or references unknown entities or properties, the implementation should throw an appropriate runtime exception.

      Specified by:
      parseQuery in interface NamedObjectParser
      Parameters:
      name - the logical name of the query (e.g., the value of @NamedQuery.name)
      queryString - the JPQL query string to validate
      Returns:
      a descriptor containing the query metadata and discovered parameters
    • parseStoredProcedure

      public NamedObjectDescriptor parseStoredProcedure(String name, String procedureName, Set<String> parameterNames)
      Validates a named stored procedure declaration.

      The implementation records the procedure name and its parameter names into a NamedObjectDescriptor for downstream consumption.

      Specified by:
      parseStoredProcedure in interface NamedObjectParser
      Parameters:
      name - the logical name of the stored procedure (e.g. the value of @NamedStoredProcedureQuery.name)
      procedureName - the database procedure name
      parameterNames - the set of parameter names declared on the stored procedure
      Returns:
      a descriptor containing the stored procedure metadata
    • close

      public void close() throws Exception
      Releases the Hibernate SessionFactory and ServiceRegistry held by this parser.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception