{"record":{"id":"3aab38dd1b55db12","repo":"hibernate/hibernate-orm","slug":"not-a-sqmselectstatement","errorCode":null,"errorMessage":"Not a SqmSelectStatement","messagePattern":"Not a SqmSelectStatement","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/criteria/CriteriaDefinition.java","lineNumber":153,"sourceCode":"\t\tquery = ((SqmSelectStatement<R>) template.query)\n\t\t\t\t.copy( SqmCopyContext.simpleContext() );\n\t}\n\n\t/**\n\t * Construct a new {@code CriteriaDefinition} based on the given\n\t * {@code CriteriaDefinition}. This overload permits changing the\n\t * query return type. It is expected that {@link #select} be called\n\t * to rewrite the selection list.\n\t *\n\t * @param template the original query\n\t * @param resultType the new return type\n\t *\n\t * @since 7.0\n\t */\n\tpublic CriteriaDefinition(CriteriaDefinition<?> template, Class<R> resultType) {\n\t\tsuper( template.getCriteriaBuilder() );\n\t\tif ( !(template.query instanceof SqmSelectStatement<?> selectStatement) ) {\n\t\t\tthrow new IllegalArgumentException( \"Not a SqmSelectStatement\" );\n\t\t}\n\t\tquery = selectStatement.createCopy( SqmCopyContext.simpleContext(), resultType );\n\t}\n\n\tpublic CriteriaDefinition(SessionFactory factory, Class<R> resultType) {\n\t\tsuper( factory.getCriteriaBuilder() );\n\t\tquery = createQuery( resultType );\n\t}\n\n\tpublic CriteriaDefinition(SessionFactory factory, Class<R> resultType, String baseHql) {\n\t\tsuper( factory.getCriteriaBuilder() );\n\t\tquery = createQuery( baseHql, resultType );\n\t}\n\n\tpublic CriteriaDefinition(SessionFactory factory, CriteriaQuery<R> baseQuery) {\n\t\tsuper( factory.getCriteriaBuilder() );\n\t\tquery = (JpaCriteriaQuery<R>) baseQuery;\n\t}","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/criteria/CriteriaDefinition.java#L135-L171","documentation":"Error \"Not a SqmSelectStatement\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Cast only select statements to SqmSelectStatement.","Check the statement type before casting."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}