improve format of error messages relating to getters/setters
This commit is contained in:
parent
1f6564d345
commit
dc9a997f5f
|
@ -485,9 +485,9 @@ public final class ReflectHelper {
|
||||||
throw new PropertyNotFoundException(
|
throw new PropertyNotFoundException(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
"Could not locate getter method for property [%s#%s]",
|
"Could not locate getter method for property '%s' of class '%s'",
|
||||||
containerClass.getName(),
|
propertyName,
|
||||||
propertyName
|
containerClass.getName()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -608,12 +608,11 @@ public final class ReflectHelper {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
"In trying to locate getter for property [%s], Class [%s] defined " +
|
"Class '%s' declares both 'get' [%s] and 'is' [%s] variants of getter for property '%s'",
|
||||||
"both a `get` [%s] and `is` [%s] variant",
|
|
||||||
propertyName,
|
|
||||||
containerClass.getName(),
|
containerClass.getName(),
|
||||||
getMethod.toString(),
|
getMethod,
|
||||||
isMethod.toString()
|
isMethod,
|
||||||
|
propertyName
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -731,9 +730,9 @@ public final class ReflectHelper {
|
||||||
throw new PropertyNotFoundException(
|
throw new PropertyNotFoundException(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
"Could not locate setter method for property [%s#%s]",
|
"Could not locate setter method for property '%s' of class '%s'",
|
||||||
containerClass.getName(),
|
propertyName,
|
||||||
propertyName
|
containerClass.getName()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,12 +152,11 @@ public class AccessStrategyHelper {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
String.format(
|
String.format(
|
||||||
Locale.ROOT,
|
Locale.ROOT,
|
||||||
"In trying to locate getter for property [%s], Class [%s] defined " +
|
"Class '%s' declares both 'get' [%s] and 'is' [%s] variants of getter for property '%s'",
|
||||||
"both a `get` [%s] and `is` [%s] variant",
|
|
||||||
propertyName,
|
|
||||||
containerClass.getName(),
|
containerClass.getName(),
|
||||||
method.toString(),
|
method.toString(),
|
||||||
isMethodVariant.toString()
|
isMethodVariant,
|
||||||
|
propertyName
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.endsWith;
|
||||||
import static org.hamcrest.CoreMatchers.startsWith;
|
import static org.hamcrest.CoreMatchers.startsWith;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
@ -61,7 +62,7 @@ public class GetAndIsVariantGetterTest {
|
||||||
fail( "Expecting a failure" );
|
fail( "Expecting a failure" );
|
||||||
}
|
}
|
||||||
catch (MappingException e) {
|
catch (MappingException e) {
|
||||||
assertThat( e.getMessage(), startsWith( "In trying to locate getter for property [id]" ) );
|
assertThat( e.getMessage(), endsWith( "variants of getter for property 'id'" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import jakarta.persistence.Id;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
@ -64,7 +63,8 @@ public class MissingSetterWithEnhancementTest {
|
||||||
}
|
}
|
||||||
catch (MappingException e) {
|
catch (MappingException e) {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Could not locate setter method for property [" + EntityWithMissingSetter.class.getName() + "#name]",
|
"Could not locate setter method for property 'name' of class '"
|
||||||
|
+ EntityWithMissingSetter.class.getName() + "'",
|
||||||
e.getMessage()
|
e.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue