Class LegacyNamedObjectParser
- All Implemented Interfaces:
AutoCloseable,NamedObjectParser,PersistenceLinter
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 Summary
Modifier and TypeMethodDescriptionvoidclose()Releases the HibernateSessionFactoryandServiceRegistryheld by this parser.static LegacyNamedObjectParserCreates a newLegacyNamedObjectParserconfigured with the supplied entity class names.parseQuery(String name, String queryString) Parses and semantically validates the given JPQL query string.parseStoredProcedure(String name, String procedureName, Set<String> parameterNames) Validates a named stored procedure declaration.
-
Method Details
-
from
Creates a newLegacyNamedObjectParserconfigured 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
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:
parseQueryin interfaceNamedObjectParser- 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
NamedObjectDescriptorfor downstream consumption.- Specified by:
parseStoredProcedurein interfaceNamedObjectParser- Parameters:
name- the logical name of the stored procedure (e.g. the value of@NamedStoredProcedureQuery.name)procedureName- the database procedure nameparameterNames- the set of parameter names declared on the stored procedure- Returns:
- a descriptor containing the stored procedure metadata
-
close
Releases the HibernateSessionFactoryandServiceRegistryheld by this parser.- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-