Vaadin 8 - validators of the HIbernate annotations

How do I make the vaadin 8 fold return the validators of the HIbernate annotations?

In the documentation it speaks only of the withValidator, but does not show how to use with the annotations as it appeared in 7.

[code]
@Entity(name=“departament”)
public class DepartamentModel extends Tz1Model {
@Size(min=1,max=30)
@Column(name=“name”,length=30,nullable=false)
private String name = getNewName() ;

public DepartamentModel() {
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

}
[/code]How to appear in red (as in the previous version) when the user places a string greater than 30.

Yes, it has the withValidator (new StringLengthValidator (“error”, 1, 30)

But I want it to validate the hibernate annotation.

You can use BeanValidationBInder to add JSR 303 validation
https://vaadin.com/docs/-/part/framework/datamodel/datamodel-forms.html
In the documentation it’s written: Bean level validation can only be performed once the bean has been updated. This means that this functionality can only be used together with setBean. You need to trigger validation manually if using readBean and writeBean. But it does work in buffered and unbuffered mode.
It does not automatically add a JSR-303 bean-level validator.(for the 2 modes but I don’t know how it can work before writeBean for buffered mode )
https://github.com/vaadin/framework/issues/8498

In this case, how to instantiate it in a generic class?

[code]
public class Tz1View extends Tz1Object {

private Tz1Window windowsForm;
private Tz1TabSheet tabSheet = new Tz1TabSheet();
private Tz1VerticalLayout tabFilter;
private Tz1VerticalLayout tabShow;
private Tz1VerticalLayout tabEdit;
private Tz1FormLayout form = new Tz1FormLayout();
private BeanValidationBinder<T> binder = new BeanValidationBinder<>(????);
private T bean

[/code]If use

private Binder<T> binder = new Tz1Binder<>(); OK, but BeanValidationBinder How to request the class T in this case?

I played tricks to instantiate this class, but here comes more problems:


BeanValidationBinder can not be used because the JSR-303 Bean Validation implementation is not found on the classpath. Use Binder instead

I always get suspicious when something seems too complicated to use. Either I’m not sure what to do or need to get back to better planning.

Reading

Https://github.com/vaadin/framework/issues/8253

It seems to me that someone in vaadin does not like notes. For what was simple now seems complex and difficult to implement. This has a very large impact on the conversion of our systems.

Does anyone here leave the validations in proprietary classes? And the interoperability between several platforms, since hibernate annotations can be used by many tools.

If I’m talking nonsense I’m sorry, but the feeling I have in these last months is to stay at 7 and leave the 8 and wait for a 9.

To use JSR-303 validation you need to have an implementation of JSR-303 validation (like hibernate-validator). It’s quite easy to use.
1/ Add a jar or a dependency in your pom.
2/ Change your code
Before
Binder binder = new Binder<>(Person.class);
After
Binder binder = new BeanValidationBinder<>(Person.class);

There is an example of use here:
https://github.com/vaadin/framework8-demo/tree/master/spring-demo