hibernate/hibernate-orm · error · PropertyNotFoundException

Object class [" + clazz.getName() + "] must declare a defaul

Error message

Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor

What it means

Error "Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java:286

	/**
	 * Retrieve the default (no arg) constructor from the given class.
	 *
	 * @param clazz The class for which to retrieve the default ctor.
	 * @return The default constructor.
	 * @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???)
	 */
	public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws PropertyNotFoundException {
		if ( isAbstractClass( clazz ) ) {
			return null;
		}

		try {
			final var constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
			ensureAccessibility( constructor );
			return constructor;
		}
		catch ( NoSuchMethodException nme ) {
			throw new PropertyNotFoundException(
					"Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor"
			);
		}
	}

	public static <T> Supplier<T> getDefaultSupplier(Class<T> clazz) {
		if ( isAbstractClass( clazz ) ) {
			throw new IllegalArgumentException( "Abstract class cannot be instantiated: " + clazz.getName() );
		}

		try {
			final var constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE );
			ensureAccessibility( constructor );
			return () -> {
				try {
					return constructor.newInstance();
				}
				catch ( InstantiationException|IllegalAccessException|InvocationTargetException e ) {

View on GitHub (pinned to fad1729dce)

Solutions

  1. Add a public/protected no-argument constructor to the entity/embeddable class.

When it happens

Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java:286 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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