{"record":{"id":"44d4f9cdd4ee66a2","repo":"hibernate/hibernate-orm","slug":"more-than-one-row-with-the-given-identifier-was-fo","errorCode":null,"errorMessage":"More than one row with the given identifier was found: {}, for class: {}","messagePattern":"More than one row with the given identifier was found: (.+?), for class: (.+?)","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleUniqueKeyEntityLoaderStandard.java","lineNumber":115,"sourceCode":"\n\t@Override\n\tpublic EntityMappingType getLoadable() {\n\t\treturn entityDescriptor;\n\t}\n\n\t@Override\n\tpublic T load(\n\t\t\tObject ukValue,\n\t\t\tLockOptions lockOptions,\n\t\t\tBoolean readOnly,\n\t\t\tSharedSessionContractImplementor session) {\n\t\tfinal var bindings = jdbcParameterBindings( ukValue, jdbcParameters, session );\n\t\tfinal List<T> list = list( jdbcSelect, bindings,\n\t\t\t\tnew SingleUKEntityLoaderExecutionContext( uniqueKeyAttributePath, ukValue, session, readOnly ) );\n\t\treturn switch ( list.size() ) {\n\t\t\tcase 0 -> null;\n\t\t\tcase 1 -> list.get( 0 );\n\t\t\tdefault -> throw new HibernateException( \"More than one row with the given identifier was found: \"\n\t\t\t\t\t\t\t\t+ ukValue + \", for class: \" + entityDescriptor.getEntityName() );\n\t\t};\n\t}\n\n\t@Override\n\tpublic Object resolveId(Object ukValue, SharedSessionContractImplementor session) {\n\t\tfinal var factory = session.getFactory();\n\t\t// todo (6.0) : cache the SQL AST and JdbcParameters\n\t\tfinal var builder = JdbcParametersList.newBuilder();\n\t\tfinal var sqlAst = LoaderSelectBuilder.createSelectByUniqueKey(\n\t\t\t\tentityDescriptor,\n\t\t\t\tsingletonList( entityDescriptor.getIdentifierMapping() ),\n\t\t\t\tuniqueKeyAttribute,\n\t\t\t\tnull,\n\t\t\t\tnew LoadQueryInfluencers( factory ),\n\t\t\t\tnew LockOptions(),\n\t\t\t\tbuilder::add,\n\t\t\t\tnew SqlAliasBaseManager(),","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleUniqueKeyEntityLoaderStandard.java#L97-L133","documentation":"Error \"More than one row with the given identifier was found: {}, for class: {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleUniqueKeyEntityLoaderStandard.java:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a unique constraint on the unique key columns or fix duplicate data; loading by unique key requires uniqueness."],"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"}