{"record":{"id":"8f62b72efb1ea9b2","repo":"hibernate/hibernate-orm","slug":"a-virtual-id-cannot-define-any-attributes","errorCode":null,"errorMessage":"A \"virtual id\" cannot define <any/> attributes : {}","messagePattern":"A \"virtual id\" cannot define <any/> attributes : (.+?)","errorType":"exception","errorClass":"IllegalAttributeType","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualIdEmbeddable.java","lineNumber":221,"sourceCode":"\t\t\tString[] rootTableKeyColumnNames,\n\t\t\tMappingModelCreationProcess creationProcess) {\n\n\t\tfinal var attributeMappings = new ImmutableAttributeMappingList.Builder( compositeType.getPropertyNames().length );\n\n\t\treturn finishInitialization(\n\t\t\t\tnavigableRole,\n\t\t\t\tbootDescriptor,\n\t\t\t\tcompositeType,\n\t\t\t\trootTableExpression,\n\t\t\t\trootTableKeyColumnNames,\n\t\t\t\tthis,\n\t\t\t\trepresentationStrategy,\n\t\t\t\t(attributeName, attributeType) -> {\n\t\t\t\t\tif ( attributeType instanceof CollectionType ) {\n\t\t\t\t\t\tthrow new IllegalAttributeType( \"A \\\"virtual id\\\" cannot define collection attributes : \" + attributeName );\n\t\t\t\t\t}\n\t\t\t\t\tif ( attributeType instanceof AnyType ) {\n\t\t\t\t\t\tthrow new IllegalAttributeType( \"A \\\"virtual id\\\" cannot define <any/> attributes : \" + attributeName );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t(column, jdbcEnvironment) -> MappingModelCreationHelper.getTableIdentifierExpression( column.getValue().getTable(), creationProcess ),\n\t\t\t\tattributeMappings::add,\n\t\t\t\t() -> {\n\t\t\t\t\tthis.attributeMappings = attributeMappings.build();\n\t\t\t\t\t// We need the attribute mapping types to finish initialization first before we can build the column mappings\n\t\t\t\t\tcreationProcess.registerInitializationCallback(\n\t\t\t\t\t\t\t\"VirtualIdEmbeddable(\" + navigableRole + \")#initColumnMappings\",\n\t\t\t\t\t\t\tthis::initColumnMappings\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tcreationProcess\n\t\t);\n\t}\n\n\t@Override\n\tpublic boolean areEqual(@Nullable Object one, @Nullable Object other, SharedSessionContractImplementor session) {","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/VirtualIdEmbeddable.java#L203-L239","documentation":"Error \"A \"virtual id\" cannot define <any/> attributes : {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when an entity with a virtual id embeddable declares <any/> attributes as part of its identifier mapping.","commonSituations":"See trigger scenarios.","solutions":["Remove <any/> attributes from the virtual id mapping; use basic or to-one attributes for the identifier."],"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"}