[Hibernate-JIRA] Created: (BVAL-224) Provide a way for accessing default implementations for XML configured bootstrap artifacts
by Gunnar Morling (JIRA)
Provide a way for accessing default implementations for XML configured bootstrap artifacts
------------------------------------------------------------------------------------------
Key: BVAL-224
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-224
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Reporter: Gunnar Morling
Using {{validation.xml}} one can specify custom implementations for constraint validator factory, message interpolator etc. Right now there is no way to delegate from within these custom implementations to the default ones. This would be possible when using the configuration API:
{code}
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
ConstraintValidatorFactory defaultFactory = configuration.getDefaultConstraintValidatorFactory();
ConstraintValidatorFactory customFactory = new CustomConstraintValidatorFactory(defaultFactory);
configuration.constraintValidatorFactory(customFactory);
{code}
One idea to allow for such a delegation is to support constructors taking the default implementation as parameter:
{code}
CustomConstraintValidatorFactory implements ConstraintValidatorFactory {
ConstraintValidatorFactory delegate;
CustomConstraintValidatorFactory(ConstraintValidatorFactory defaultFactory) {
this.delegate = defaultFactory;
}
}
{code}
For XML-configured artifacts the runtime could invoke this delegate constructor if existent, otherwise the default constructor could be invoked.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (BVAL-235) Support parameterized payload attributes
by Sebastian Thomschke (JIRA)
Support parameterized payload attributes
----------------------------------------
Key: BVAL-235
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-235
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Affects Versions: 1.0 final
Reporter: Sebastian Thomschke
JSR303's payload attribute values are limited to class references.
The idea is to allow the specification of an additional String value for each payload declaration allowing more flexible configurations.
For example:
public @interface Payload {
Class< ? > type();
String value();
}
@interface MinLength {
Payload[] payload() default {};
// ...
}
class Account
{
@MinLength(value=4, payload = {
@Payload(type=ErrorCode.class, value="1234"),
@Payload(type=When.class, value="groovy:this.owner != null && this.foobar > 3")
})
String name;
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months
[Hibernate-JIRA] Created: (HV-492) Validation of CGLIB enhanced Objects always return null
by Christian Fehmer (JIRA)
Validation of CGLIB enhanced Objects always return null
-------------------------------------------------------
Key: HV-492
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-492
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.2.0.Beta2, 4.1.0.Final
Environment: Hibernate Validator 4.1.0-final and 4.2.0-BETA2, cglib 2.2
Reporter: Christian Fehmer
A validation of a cglib enhanced object will always validate "null".
The validator (i tested it with an custom validator) always gets "null" as the value in the isValid method. The cglib enhanced object has a field "selection" and a getter/setter pair for this field. The hibernate validator uses the org.hibernate.validator.util.ReflectionHelper to access the field selection directly. That fails on a cglib enhanced object.
My workaround for now: I replaced the org.hibernate.validator.util.ReflectionHelper.getValue method. When object is a cglib enhanced object i invoke the getter method instead of accessing the field directly.
replaced method:
public static Object getValue(Member member, Object object) {
Object value = null;
if (member instanceof Method) {
...
} else if (member instanceof Field) {
// FIX: use getter method on cglib fields
if (object.getClass().getName().contains("$$")) {
String methodName = member.getName();
methodName = "get"+ String.valueOf(methodName.charAt(0)).toUpperCase()+ methodName.substring(1);
try {
Method method = member.getDeclaringClass().getMethod(
methodName);
method.setAccessible(true);
value = method.invoke(object);
} catch (Exception e) {
throw new ValidationException("Unable to access "
+ methodName, e);
}
} else {
...
}
}
return value;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 3 months