{"record":{"id":"6ba2e4caf2648182","repo":"hibernate/hibernate-orm","slug":"property-qualify-classdetails-getname-att","errorCode":null,"errorMessage":"Property '\" + qualify( classDetails.getName(), attributeMemberDetails.getName() ) + \"' has an unbound type and no explicit target entity (resolve this generics usage issue or set an explicit target attribute with '@OneToMany(target=)' or use an explicit '@Type')","messagePattern":"Property '\" \\+ qualify\\( classDetails\\.getName\\(\\), attributeMemberDetails\\.getName\\(\\) \\) \\+ \"' has an unbound type and no explicit target entity \\(resolve this generics usage issue or set an explicit target attribute with '@OneToMany\\(target=\\)' or use an explicit '@Type'\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java","lineNumber":295,"sourceCode":"\t\treturn classLevelAccessType;\n\t}\n\n\tpublic Iterable<MemberDetails> propertyIterator() {\n\t\treturn attributeMembers;\n\t}\n\n\tprivate static List<MemberDetails> verifyAndInitializePersistentAttributes(\n\t\t\tClassDetails classDetails,\n\t\t\tTypeVariableScope typeAtStake,\n\t\t\tMap<String, MemberDetails> attributeMemberMap) {\n\t\tfinal ArrayList<MemberDetails> output = new ArrayList<>( attributeMemberMap.size() );\n\t\tfor ( var attributeMemberDetails : attributeMemberMap.values() ) {\n\t\t\tif ( !attributeMemberDetails.resolveRelativeType( typeAtStake ).isResolved()\n\t\t\t\t\t&& !discoverTypeWithoutReflection( attributeMemberDetails ) ) {\n\t\t\t\tfinal String msg = \"Property '\" + qualify( classDetails.getName(), attributeMemberDetails.getName() ) +\n\t\t\t\t\t\t\"' has an unbound type and no explicit target entity (resolve this generics usage issue\" +\n\t\t\t\t\t\t\" or set an explicit target attribute with '@OneToMany(target=)' or use an explicit '@Type')\";\n\t\t\t\tthrow new AnnotationException( msg );\n\t\t\t}\n\t\t\toutput.add( attributeMemberDetails );\n\t\t}\n\t\treturn toSmallList( output );\n\t}\n\n\tprivate AccessType determineLocalClassDefinedAccessStrategy() {\n\t\tfinal var access = classDetails.getDirectAnnotationUsage( Access.class );\n\t\treturn access == null ? AccessType.DEFAULT : AccessType.getAccessStrategy( access.value() );\n\t}\n\n\tprivate static boolean discoverTypeWithoutReflection(MemberDetails memberDetails) {\n\t\tif ( memberDetails.hasDirectAnnotationUsage( TargetEmbeddable.class ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( memberDetails.hasDirectAnnotationUsage( Basic.class ) ) {\n\t\t\treturn true;","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java#L277-L313","documentation":"verifyAndInitializePersistentAttributes checks that every persistent attribute's type resolves; if the member's relative type is still an unbound type variable and discoverTypeWithoutReflection finds no explicit target, an AnnotationException is thrown naming the qualified property. Hibernate cannot determine the entity class for the generic member, so it asks you to bind the type parameter or declare a target explicitly.","triggerScenarios":"A mapped class declares @OneToMany List<T> items or @ElementCollection Set<T> while T is never bound to a concrete entity (generic base class used directly as an entity, or subclass type argument lost); no @OneToMany(targetEntity=...), @ManyToOne(targetEntity=...), @Type, or equivalent is present. Fires during PropertyContainer initialization, before any DDL or SQL runs.","commonSituations":"Abstract generic DAO/base-entity classes reused as mapped superclasses without concrete type arguments; entities inside generic hierarchies where Jandex/reflection cannot see the resolved argument (wildcards, recursive generics, enhanced proxy classes); third-party base libraries with @OneToMany on T; upgrading Hibernate versions that previously guessed the type from reflection.","solutions":["Add an explicit target: @OneToMany(targetEntity = Item.class) (or @ManyToOne targetEntity, @OneToOne targetEntity) on the generic member.","Add @Type(ClassThatHandlesIt.class) if the member is a basic/composite value rather than an association.","Bind the type variable by making the concrete subclass the mapped entity and passing the real type argument to the generic base.","Restructure: move the generic collection out of the mapped hierarchy into concrete subclasses that declare typed members."],"exampleFix":"// before\npublic abstract class AbstractOrder<T extends Item> {\n    @OneToMany(mappedBy = \"order\", cascade = CascadeType.ALL)\n    private List<T> items; // T unbound\n}\n\n// after\npublic abstract class AbstractOrder<T extends Item> {\n    @OneToMany(targetEntity = Item.class, mappedBy = \"order\", cascade = CascadeType.ALL)\n    private List<T> items;\n}\n// or map concrete subclasses: class SalesOrder extends AbstractOrder<SalesItem> and ensure the\n// type argument is resolvable","handlingStrategy":"validation","validationCode":"// reject unbound generic members on entity classes before Hibernate sees them\nfor (Field f : Order.class.getDeclaredFields()) {\n    if (isPersistent(f) && f.getGenericType() instanceof TypeVariable) {\n        throw new IllegalStateException(\"Unbound generic member: \" + f\n            + \" - set targetEntity/@Type or bind the type argument\");\n    }\n}","typeGuard":"boolean isResolvedMember(Field f) {\n    Type t = f.getGenericType();\n    return !(t instanceof TypeVariable) && !(t instanceof Class<?> c && c.getTypeParameters().length > 0);\n}","tryCatchPattern":"try {\n    metadata = sources.buildMetadata();\n} catch (AnnotationException e) {\n    failBuild(\"Unresolved generic type in mapping: \" + e.getMessage());\n}","preventionTips":["Always pair generic association members with targetEntity.","Instantiate generic base classes with concrete type arguments before mapping them.","Cover abstract generic mapped superclasses with a subclass mapping test."],"tags":["hibernate","orm","generics","unresolved-type","mapping","target-entity"],"backgroundTag":"unresolved-generic-mapping-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}