{"record":{"id":"937384fef9a63053","repo":"hibernate/hibernate-orm","slug":"could-not-configure-c3p0-e-getmessage","errorCode":null,"errorMessage":"Could not configure c3p0: \" + e.getMessage()","messagePattern":"Could not configure c3p0: \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"ConnectionProviderConfigurationException","httpStatus":null,"severity":"error","filePath":"hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java","lineNumber":232,"sourceCode":"\t\t\t\t\t\t\tDEFAULT_MAX_POOL_SIZE ),\n\t\t\t\t\tfetchSize\n\t\t\t);\n\t\t\tif ( !connection.getAutoCommit() ) {\n\t\t\t\tconnection.rollback();\n\t\t\t}\n\t\t}\n\t\tcatch (SQLException e) {\n\t\t\tthrow new JDBCConnectionException( \"Could not create connection\", e );\n\t\t}\n\t}\n\n\tprivate DataSource createDataSource(String jdbcUrl, Properties connectionProps, Map<String, Object> poolProperties) {\n\t\ttry {\n\t\t\treturn pooledDataSource( unpooledDataSource( jdbcUrl, connectionProps ), poolProperties );\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tCONNECTION_INFO_LOGGER.unableToInstantiateConnectionPool( e );\n\t\t\tthrow new ConnectionProviderConfigurationException(\n\t\t\t\t\t\"Could not configure c3p0: \" + e.getMessage(),  e );\n\t\t}\n\t}\n\n\tprivate void loadDriverClass(String jdbcDriverClass) {\n\t\tif ( jdbcDriverClass == null ) {\n\t\t\tCONNECTION_INFO_LOGGER.jdbcDriverNotSpecified();\n\t\t}\n\t\telse {\n\t\t\ttry {\n\t\t\t\tserviceRegistry.requireService( ClassLoaderService.class ).classForName( jdbcDriverClass );\n\t\t\t}\n\t\t\tcatch (ClassLoadingException e) {\n\t\t\t\tthrow new ClassLoadingException( \"JDBC Driver class \" + jdbcDriverClass + \" not found\", e );\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-c3p0/src/main/java/org/hibernate/c3p0/internal/C3P0ConnectionProvider.java#L214-L250","documentation":"getSortExpressions(...) reads the select-item indexes recorded on the SortSpecification when the SQL AST node was built. This IllegalStateException is a defensive internal check claiming the indexes array is null; in the current code the field is final and always computed in the constructor from the sort expression, so a null can only come from a hand-built or mutated SortSpecification outside the normal SQM-to-SQL pipeline. Treat it as framework-internal corruption, not a query-authoring mistake.","triggerScenarios":"Custom code constructing SortSpecification subclasses or replacing sort expressions after construction and then running the query through full-join emulation (MySQL/MariaDB/Sybase/H2/TiDB); reflection-based mutation; a Hibernate regression where a SortSpecification is created without a SqlSelectionExpression-based expression.","commonSituations":"Extensions that post-process the SQL AST (custom translators, auditing/rewriting layers); version upgrades that changed SortSpecification constructors; rarely, users building native SQL AST by hand.","solutions":["Upgrade Hibernate - the indexes contract changed across 6.x/7.x and bugs here get fixed.","If you build SortSpecification yourself, construct it from an expression that wraps a SqlSelectionExpression so indexes are derived, or via the public constructors only.","Avoid mutating SQL AST nodes after the translator receives them.","Report to HHH with the stack trace if no custom AST code is involved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return query.getResultList();\n} catch ( IllegalStateException e ) {\n    if ( e.getMessage() != null && e.getMessage().contains(\"missing selection indexes\") ) {\n        // framework-internal: capture mapping + query and file an HHH issue\n        logHibernateIssue( e, currentQuery );\n        throw e;\n    }\n    throw e;\n}","preventionTips":["Do not mutate or hand-construct SortSpecification/SQL AST nodes after handing a query to Hibernate.","Keep SQL-AST rewriting extensions in sync with each Hibernate upgrade.","Isolate custom AST manipulations behind integration tests that run the translated SQL."],"tags":["internal","sql-ast","sort","full-join"],"backgroundTag":"sql-ast-internal-invariant","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}