hibernate/hibernate-orm · error · UnsupportedOperationException

Wrap strategy not known for this Java type: " + getTypeName(

Error message

Wrap strategy not known for this Java type: " + getTypeName()

What it means

The write-back mirror of unwrap: JavaTypeBasicAdaptor.wrap() throws UnsupportedOperationException because a bare adaptor cannot construct values. Reading a column into an attribute backed only by an adaptor — with no converter or JdbcType doing the hydration — fails here.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/JavaTypeBasicAdaptor.java:49

				"Could not determine recommended JdbcType for '" + getTypeName() + "'"
		);
	}

	@Override
	public boolean useObjectEqualsHashCode() {
		return true;
	}

	@Override
	public <X> X unwrap(T value, Class<X> type, WrapperOptions options) {
		throw new UnsupportedOperationException(
				"Unwrap strategy not known for this Java type: " + getTypeName()
		);
	}

	@Override
	public <X> T wrap(X value, WrapperOptions options) {
		throw new UnsupportedOperationException(
				"Wrap strategy not known for this Java type: " + getTypeName()
		);
	}

	@Override
	public String toString() {
		return "JavaTypeBasicAdaptor(" + getTypeName() + ")";
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Provide the JdbcType/converter side so wrap() is bypassed entirely
  2. Implement wrap() in a proper AbstractClassJavaType subclass
  3. Replace the adaptor registration with a complete BasicType (JavaType + JdbcType pair)

Example fix

// before
Money m = javaType.wrap(resultSet.getString(1), options); // adaptor -> throws

// after
Money m = Money.parse(resultSet.getString(1)); // converter/JavaType owns conversion
Defensive patterns

Strategy: type-guard

Validate before calling

static boolean hasRealWrap(JavaType<?> jt) {
    return !(jt instanceof org.hibernate.type.descriptor.java.spi.JavaTypeBasicAdaptor);
}

Type guard

static boolean wrapSafe(JavaType<?> javaType) {
    return !(javaType instanceof org.hibernate.type.descriptor.java.spi.JavaTypeBasicAdaptor);
}

Try / catch

try {
    T v = javaType.wrap(raw, options);
} catch (UnsupportedOperationException e) {
    // hydrate manually until the registration supplies conversion behavior
    T v = manuallyHydrate(raw, javaType.getJavaTypeClass());
}

Prevention

When it happens

Trigger: Result-set hydration of an attribute whose descriptor is a bare adaptor; generic wrap() calls in custom JdbcTypes; registrations that supplied type identity but no conversion behavior.

Common situations: Same root cause as the unwrap variant: incomplete custom type registrations, scaffolding types left in mappings, or integrations assuming default conversion exists.

Related errors


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