[
http://opensource.atlassian.com/projects/hibernate/browse/HV-448?page=com...
]
Hardy Ferentschik edited comment on HV-448 at 3/10/11 3:56 AM:
---------------------------------------------------------------
This is indeed caused by HV-421. The problem is that
{{DummyServiceImpl#doFailWithEmptyArg()}} adds a parameter constraint to
{{DummyService#doFailWithEmptyArg()}}. Following to the Programming by Contract definition
such a strengething of a method's precondition in sub-types is not allowed. The reason
is that a client (in your case {{ValidationAspectTest}}) only sees the base type and
can't know about the additional constraints from the sub-type/implementation.
We settled on a conservative approach for this in HV 4.2 and allow parameter constraints
only at the highest declaration of a method in an inheritance hierarchy, in your case
{{DummyService}}. That way the client clearly sees the preconditions he has to fulfull
when invoking a given method.
Actually the stacktrace is saying this:
{code}
Caused by: javax.validation.ConstraintDeclarationException: Only the root method of an
overridden method in an inheritance hierarchy may be annotated with parameter constraints.
The following method itself has no parameter constraints but it is not defined on a
sub-type of class org.hibernate.hv448.dummyservice.DummyServiceImpl: MethodMetaData
[method=public abstract void
org.hibernate.hv448.dummyservice.DummyService.doFailWithEmptyArg(java.lang.String),
parameterMetaData=[ParameterMetaData [type=class java.lang.String], [index=0], name=arg0],
constraints=[], isCascading=false]], constraints=[], isCascading=false,
hasParameterConstraints=false]
{code}
I'll try to make this message a bit clearer, there should only the problematic method
be mentioned, not the internally used MethodMetaData object.
You can find more information on this topic and the discussion which led to the current
approach at HV-421 and in the [announcement for
Beta2|http://in.relation.to/Bloggers/HibernateValidator420Beta2].
was (Author: gunnar.morling):
This is indeed caused by HV-421. The problem is that
{{DummyServiceImpl#doFailWithEmptyArg()}} adds a parameter constraint to
{{DummyService#doFailWithEmptyArg()}}. Following to the Programming by Contract definition
such a strengething of a method's precondition in sub-types is not allowed. The reason
is that a client (in your case {{ValidationAspectTest}}) only sees the base type and
can't know about the additional constraints from the sub-type/implementation.
We settled on a conservative approach for this in HV 4.2 and allow parameter constraints
only at the highest declaration of a method in an inheritance hierarchy, in your case
{{DummyService}}. That way the client clearly sees the preconditions he has to fulfull
when invoking a given method.
Actually the stacktrace is saying this:
{code}
Caused by: javax.validation.ConstraintDeclarationException: Only the root method of an
overridden method in an inheritance hierarchy may be annotated with parameter constraints.
The following method itself has no parameter constraints but it is not defined on a
sub-type of class org.hibernate.hv448.dummyservice.DummyServiceImpl: MethodMetaData
[method=public abstract void
org.hibernate.hv448.dummyservice.DummyService.doFailWithEmptyArg(java.lang.String),
parameterMetaData=[ParameterMetaData [type=class java.lang.String], [index=0], name=arg0],
constraints=[], isCascading=false]], constraints=[], isCascading=false,
hasParameterConstraints=false]
{code}
I'll try to make this message a bit clearer, there should only the problematic method
be mentioned, not the internally used MethodMetaData object.
You can find more information on this topic and the discussion which led to the current
approach at HV-421 and in the
[
http://in.relation.to/Bloggers/HibernateValidator420Beta2|announcement for Beta2].
Regression in beta2
-------------------
Key: HV-448
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-448
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.2.0.Beta2
Reporter: David J. M. Karlsen
Attachments: DummyBean.java, DummyService.java, DummyServiceImpl.java,
ValidateMethod.java, ValidationAspect.java, ValidationAspectTest-context.xml,
ValidationAspectTest.java
The attached test and aspect used to pass just fine - but now fails with beta2.
--
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