[Hibernate-JIRA] Created: (HV-462) Allow ordered validator's annotations
by Pavla Nováková (JIRA)
Allow ordered validator's annotations
-------------------------------------
Key: HV-462
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-462
Project: Hibernate Validator
Issue Type: New Feature
Affects Versions: 4.1.0.Final
Reporter: Pavla Nováková
1) Consider domain object with simple constraints (just to demonstrate required feature, my real example uses custom cost-expensive validation of pictures):
{code}
public class DomainObject {
@Size(max=50) // constraint 1a
@Pattern(regexp="[a-z]*") // constraint 1b
private String name;
@Size(max=20) // constraint 2a
@URL // constraint 2b
private String email;
@Size(max=100) // constraint 3a
@Pattern(regexp="[0-9]*") // constraint 3b
private String password;
{code}
2) Consider validation requirements:
* all properties should be validated together (like one virtual group)
* FOR EACH PROPERTY validation should occur in ordered steps given by order of annotations for given property (if first validation step fails, SKIP following validation process on given property and add validation message specific to failed / last validated constraint for the property)
3) Why it is useful:
* simple cost-effective validation followed by cost-expensive validation (not executed if simple constraint fails)
* we get just the "main and specific validation error" (otherwise we have to iterate over all errors "to find the cause" or we display two or more errors for one property which is not user-friendly according my opinion)
3) What is unusable:
* groups and group sequences (it is not possible to create proper combination of groups and sequences for more than one property with two or more constraints)
* composed constraints (@ReportAsSingleViolation included)
** we cannot use @ReportAsSingleViolation since we want specific message for each failed constraint
** and main problem is: if we use composed constraints all constraints are evaluated for given property
4) Proposed solution:
* add optional order attribute to validator annotations and stop validation on first failure if order is specified
* possibly this can be configured on global validator level with property "skipOnFirstFailure" together with some given convention for annotation order
Please let me know if need better explanation or working examples.
--
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
11 years, 10 months
[Hibernate-JIRA] Created: (BVAL-255) Simplify GroupSequence for ordered checking
by Cemo Koc (JIRA)
Simplify GroupSequence for ordered checking
-------------------------------------------
Key: BVAL-255
URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-255
Project: Bean Validation
Issue Type: New Feature
Components: spec-general
Affects Versions: 1.0 final
Reporter: Cemo Koc
The JSR 303 is becoming defacto solution at enterprise level projects however I think that it has a significant useless part. The current implementation states group sequence must be utilized to ordered validation. In order to use group sequence, one has to define interfaces for each order sequence such this:
{code}
public class AccountBean {
@CheapValidation(groups=Name1.class)
@ExpensiveValidation(groups=Name2.class)
@VeryExpensiveValidation(groups=Name3.class)
String name;
@CheapValidation(groups=Surname1.class)
@ExpensiveValidation(groups=Surname2.class)
@VeryExpensiveValidation(groups=Surname3.class)
String surname;
public interface Name1 {}
public interface Name2 {}
public interface Name3 {}
@GroupSequence({Name1.class, Name2.class, Name3.class})
public interface Name {}
public interface Surname1 {}
public interface Surname2 {}
public interface Surname3 {}
@GroupSequence({Surname1.class, Surname2.class, Surname3.class})
public interface Surname {}
}
{code}
Look the code how it is ugly and useless. What I am offering is a simplified version of ordering such this:
{code}
public class AccountBean {
@CheapValidation(order=0,groups=Name1.class)
@ExpensiveValidation(order=1,groups=Name2.class)
@VeryExpensiveValidation(order=2,groups=Name3.class)
String name;
@CheapValidation(order=0,groups=Surname1.class)
@ExpensiveValidation(order=1,groups=Surname2.class)
@VeryExpensiveValidation(order=2,groups=Surname3.class)
String surname;
}
{code}
Almost all enterprise projects needs such kind of things. For example lets say that you want to validate email field by NotEmpty and UniqueAtDatabase. Why should we show two error messages in this case? Shortly, to increase usability and adaptability please solve this issue.
PS: This issue is cross posted here and forums.
https://forum.hibernate.org/viewtopic.php?f=26&t=1007328
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
11 years, 10 months
[Hibernate-JIRA] Created: (BVAL-285) ValidatorFactory#close should clearly state post condidtions
by Hardy Ferentschik (JIRA)
ValidatorFactory#close should clearly state post condidtions
-------------------------------------------------------------
Key: BVAL-285
URL: https://hibernate.onjira.com/browse/BVAL-285
Project: Bean Validation
Issue Type: Improvement
Components: spec-general
Affects Versions: 1.1.next
Reporter: Hardy Ferentschik
The Javadocs for ValidatorFactory#close says:
{quote}
After the _ValidatorFactory_ instance is closed, it is not allowed to call:
* methods of this _ValidatorFactory_ instance
* methods of _Validator_ instances created by this _ValidatorFactory_
{quote}
It does, however, not specified what happens if such a method is called. I think with this wording a post conditions needs to be specified, eg a _ValidationException_ will be thrown. Otherwise the docs should say that the behavior is unspecified if any of the mentioned methods is called after calling _close()_
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
11 years, 10 months
[Hibernate-JIRA] Created: (HHH-3502) getIdentifierMethod of BasicLazyInitializer does not match if method invoked through an interface with different return type
by Sean Bridges (JIRA)
getIdentifierMethod of BasicLazyInitializer does not match if method invoked through an interface with different return type
----------------------------------------------------------------------------------------------------------------------------
Key: HHH-3502
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3502
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Reporter: Sean Bridges
Priority: Minor
I have an entity interface,
public interface IEntity {
public Object getId();
}
and I have an entity, say User that implements this interface with an id method
@Id
public Long getId() {
return id;
}
I can call getId() on an uninitialized proxy with,
user.getId()
however, if I call getId() in this way,
((IEntity) user)).getId()
I get org.hibernate.LazyInitializationException: could not initialize proxy - no Session
Looking at the code, BasicLazyInitializer has these lines,
else if ( isUninitialized() && method.equals(getIdentifierMethod) ) {
return getIdentifier();
}
the method.equals(getIdentifierMethod) returns false. The methods are not equal() because they have different return types (this is allowed in 1.5 with covariant return types).
Hibernate should not use Method.equals(), but should instead use the code below (modified from Method.equals(Object)),
public boolean equalsIgnoringReturnType(Method m1, Method m2) {
if ((m1.getDeclaringClass() != m2.getDeclaringClass()) {
return false;
}
if (m1.getName() != m2.getName()) {
return false;
}
Class[] params1 = m1.getParameterTypes();
Class[] params2 = m2.getParameterTypes();
if (params1.length != params2.length) {
return false;
}
for (int i = 0; i < params1.length; i++) {
if (params1[i] != params2[i])
return false;
}
return true;
}
--
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
11 years, 10 months