{"record":{"id":"29b607c85fa8b754","repo":"hibernate/hibernate-orm","slug":"could-not-find-selectable-s-in-embeddable-type-29b607","errorCode":null,"errorMessage":"Could not find selectable [%s] in embeddable type [%s] for XML processing.","messagePattern":"Could not find selectable \\[(.+?)\\] in embeddable type \\[(.+?)\\] for XML processing\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/XmlHelper.java","lineNumber":963,"sourceCode":"\t\t\t\t\t\t\t\tappender.append( START_TAG );\n\t\t\t\t\t\t\t\tconvertedBasicValueToString( appender, arrayElement, options, elementJavaType, elementJdbcType );\n\t\t\t\t\t\t\t\tappender.append( END_TAG );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new UnsupportedOperationException( \"Unsupported JdbcType nested in struct: \" + jdbcType );\n\t\t}\n\t}\n\n\tprivate static int getSelectableMapping(\n\t\t\tEmbeddableMappingType embeddableMappingType,\n\t\t\tString name) {\n\t\tfinal int selectableIndex = embeddableMappingType.getSelectableIndex( name );\n\t\tif ( selectableIndex == -1 ) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"Could not find selectable [%s] in embeddable type [%s] for XML processing.\",\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tembeddableMappingType.getMappedJavaType().getJavaTypeClass().getName()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn selectableIndex;\n\t}\n\n\tpublic static boolean isValidXmlName(String name) {\n\t\tif ( name.isEmpty()\n\t\t\t\t|| !isValidXmlNameStart( name.charAt( 0 ) )\n\t\t\t\t|| name.regionMatches( true, 0, \"xml\", 0, 3 ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tfor ( int i = 1; i < name.length(); i++ ) {\n\t\t\tif ( !isValidXmlNameChar( name.charAt( i ) ) ) {","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/XmlHelper.java#L945-L981","documentation":"During XML aggregate parsing, Hibernate looked up an element name from the stored data among the embeddable's selectables and found no match. The parser resolves tags by selectable (attribute) name, so any element unknown to the current mapping fails with 'Could not find selectable'.","triggerScenarios":"Loading an XML aggregate where stored rows contain element names that no longer (or do not yet) exist in the embeddable: a field was renamed without migrating data, extra elements were added by another writer, or the column was written by a different application version.","commonSituations":"Renaming embeddable attributes across releases; sharing one column between services with different models; restored backups paired with newer code.","solutions":["Keep attribute names stable, or migrate stored element names together with the rename.","Remove stray elements from stored rows so data matches the deployed mapping.","If tags are explicit (e.g. @Struct/@Column names), make them match the stored tags exactly."],"exampleFix":"-- PostgreSQL: rename element tags together with the field rename\n-- code: String postCode -> String zipCode\nUPDATE t SET xml_col = REPLACE(xml_col, '<postCode>', '<zipCode>');\nUPDATE t SET xml_col = REPLACE(xml_col, '</postCode>', '</zipCode>');","handlingStrategy":"validation","validationCode":"static void assertTagsMatchMapping(Class<?> embeddable, Set<String> storedTags) {\n    Set<String> fields = Arrays.stream(embeddable.getDeclaredFields())\n        .map(Field::getName).collect(Collectors.toSet());\n    for (String tag : storedTags) {\n        if (!fields.contains(tag)) {\n            throw new IllegalStateException(\n                \"Stored XML element <\" + tag + \"> has no field in \" + embeddable.getName());\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return session.find(Person.class, id);\n} catch (IllegalArgumentException ex) {\n    if (ex.getMessage() != null && ex.getMessage().contains(\"Could not find selectable\")) {\n        quarantine(id, ex.getMessage()); // row layout does not match deployed mapping\n        return null;\n    }\n    throw ex;\n}","preventionTips":["Pair every embeddable field rename with a data migration updating stored tags.","Keep explicit, stable column/tag names on aggregate fields.","Compare stored element names with the mapping during staging deployments."],"tags":["hibernate","xml","xml-aggregate","schema-drift","field-mapping"],"backgroundTag":"schema-field-mismatch","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}