Ich habe verschiedene JPA / Hibernate Validation Annotation inzwischen gesehen.
Annotation an Attributen
Annotation an Funktionen
und Annotation bei Parameterübergaben
was ist ganz konkret der Unterschied, welche Vorteile hat man hierdurch und vor allem wann sollte was eingesetzt werden?
Annotation an Attributen
Code:
@Entity
class MyClass {
@NotBlank
private String text;
...
}
Annotation an Funktionen
Code:
@Entity
class MyClass {
@Annotation
void setName( String name ) {
.....
}
}
und Annotation bei Parameterübergaben
Code:
@Entity
class MyClass {
public MyClass (@NotBlankString name ) {
.....
}
void setName( @NotBlank String name ) {
.....
}
}