Skip to content

Instantly share code, notes, and snippets.

View gunnarmorling's full-sized avatar
🤓
Streaming data changes, one at a time.

Gunnar Morling gunnarmorling

🤓
Streaming data changes, one at a time.
View GitHub Profile
@GroupSequence(B.class, Foo.class)
class B {
@NotNull
String b;
}
class A extends B {
@NotNull(groups = A.class)
String a;
}
@gunnarmorling
gunnarmorling / 1_SimpleMapping.java
Created April 25, 2011 12:20
HV-431: New approach by removing creational context from ConstraintDef completely
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
.property( "name", METHOD )
.constraint( new SizeDef()
.message( "name too short" )
.min( 3 ) )
.constraint( new NotNullDef() )
.property( "numberOfHelpers", FIELD )
.constraint( new MinDef().value( 1 ) );
@gunnarmorling
gunnarmorling / A1_NumberOfNodes_SingleNode.java
Created March 8, 2012 17:09
Options for property pathes for method validation
//Option #A1 (currently in draft): Have a single node representing a parameter or return value *and* the hosting method/constructor
//path to @NotNull on the "book" parameter of addBook()
Node(name=book, methodDescriptor=..., parameterDescriptor=..., constructorDescriptor=null)
//path to @NotNull on the "title" attribute of the book passed as argument to addBook()
Node(name=book, methodDescriptor=..., parameterDescriptor=..., constructorDescriptor=null)
Node(name=title, methodDescriptor=null, parameterDescriptor=null, constructorDescriptor=null)
//path to @NotNull on the "title" attribute of the 4th book in the list passed as argument to addAllBooks()
@gunnarmorling
gunnarmorling / gist:2296176
Created April 3, 2012 23:04 — forked from hferentschik/gist:2293497
Hibernate Validator 4.3.0.Beta1

Moving along the road to a Hibernate Validator 4.3 release I am happy to announce the release of Hibernate Validator 4.3.0.Beta1.

One of our foci this time around was to address existing caching issues. HV-479 addresses the problem that the constraint metadata for a given class would be cached in the so called BeanMetaDataManager without a appropriate eviction policy. In most cases this should not be a problem, but for long running applications with for example hot redeploys it could be. We resolved this issue by introducing SoftLimitMRUCache which has an upper bound for the cached metadata.

HV-564 is another caching related issue. Initially ConstraintValidator instances were only cached if they where created by the Hibernate Validator specific _ConstraintValidatorFact

@gunnarmorling
gunnarmorling / gist:3085246
Created July 10, 2012 18:13
Questions for BV EG
* What approach for cross-parameter validation should be followed?
* Should method validation methods be defined on j.v.Validator or a dedicated new interface?
* Need a proposal for split of message interpolator and resource bundle locator
* Need final decision around configuration source (purpose - do we really need extensibility here, name, null behavior)
* ValidatorFactory#close() seems problematic; doesn't this require to check whether the factory is still open whenever a validator is used?

Hibernate Validator 5.0.0.Alpha2 and 4.3.1.Final

Today it's my pleasure to announce the simultaneous release of Hibernate Validator 5.0.0.Alpha2 and 4.3.1.Final.

Hibernate Validator 4.3

While we're heavily working on Hibernate Validator 5 in order to implement revision 1.1 of the Bean Validation spec, we decided to do a maintenance release of Hibernate Validator 4.3, the reference implementation of Bean Validation 1.0.

context.buildConstraintViolationWithTemplate( message )
.addNode( "placeOrder", Kind.METHOD )
.addNode( "arg0", 0, /*index */ Kind.PARAMETER )
.addConstraintViolation();
context.buildConstraintViolationWithTemplate( message )
.addNode( "placeOrder", Kind.METHOD )
.addNode( "retval" Kind.RETURN_VALUE )
.addConstraintViolation();
//Option #A1 (currently in draft): Have a single node representing a parameter or return value *and* the hosting method/constructor
//path to @NotNull on the "book" parameter of addBook()
Node(name=book, methodDescriptor=..., parameterDescriptor=..., constructorDescriptor=null)
//path to @NotNull on the "title" attribute of the book passed as argument to addBook()
Node(name=book, methodDescriptor=..., parameterDescriptor=..., constructorDescriptor=null)
Node(name=title, methodDescriptor=null, parameterDescriptor=null, constructorDescriptor=null)
//path to @NotNull on the "title" attribute of the 4th book in the list passed as argument to addAllBooks()
interface NodeBuilderCustomizableContextBase <T> {
T inIterable();
ConstraintValidatorContext addConstraintViolation();
}
interface TerminalNodeBuilderCustomizableContext extends NodeBuilderCustomizableContextBase<TerminalNodeContextBuilder> {
}
@Validated
@ValidateExecutableTypes(ALL)
public class Bar {
@Validated(OFF)
Foo getFoo() {
}
}