hibernate/hibernate-orm · error · AnnotationException

Embeddable class '<componentClassName>' has properties mappe

Error message

Embeddable class '<componentClassName>' has properties mapped to two different tables (all properties of the embeddable class must map to the same table)

What it means

Error "Embeddable class '<componentClassName>' has properties mapped to two different tables (all properties of the embeddable class must map to the same table)" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java:307

			MemberDetails attributeMemberDetails,
			@Nullable AnnotatedColumns columns,
			ClassDetails declaringClass) {
		//AnnotatedColumns.checkPropertyConsistency( ); //already called earlier
		// Check table matches between the component and the columns
		// if not, change the component table if no properties are set
		// if a property is set already the core cannot support that
		assert columns == null || property.getValue().getTable() == columns.getTable();
		setTable( property.getValue().getTable() );
		addProperty( property, attributeMemberDetails, declaringClass );
	}

	private void setTable(Table table) {
		if ( !table.equals( getTable() ) ) {
			if ( component.getPropertySpan() == 0 ) {
				component.setTable( table );
			}
			else {
				throw new AnnotationException(
						"Embeddable class '" + component.getComponentClassName()
						+ "' has properties mapped to two different tables"
						+ " (all properties of the embeddable class must map to the same table)"
				);
			}
			if ( parent instanceof ComponentPropertyHolder parentComponentHolder ) {
				parentComponentHolder.setTable( table );
			}
		}
	}

	@Override
	public Join addJoin(JoinTable joinTable, boolean noDelayInPkColumnCreation) {
		return parent.addJoin( joinTable, noDelayInPkColumnCreation );
	}

	@Override
	public Join addJoin(JoinTable joinTable, Table table, boolean noDelayInPkColumnCreation) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Map all properties of the embeddable class to the same table (fix @Column(table=...) overrides).

When it happens

Trigger: An @Embeddable / @Embedded / @ElementCollection mapping violates an embeddable mapping constraint.

Common situations: Embeddables with @Id members, inheritance, recursive composition, or properties split across multiple tables; or @Convert/@EmbeddedTable placed where unsupported.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/c33e70a77caa6415. Report an issue: GitHub.