It would be nice to have a unique constraint for size instead of one for each type.
That is, instead of writting a code as this one:
Code:
public class Invoice {
@Max(99999)
private Integer code;
@Length(max=40)
private String concept;
@Max(999999999999l)
private BigDecimal amount;
@Size(max=60)
private Collection<InvoiceDetail> details;
...
}
It's better to write the Invoice class in this way:
Code:
public class Invoice {
@Size(max=5)
private Integer code;
@Size(max=40)
private String concept;
@Size(max=12)
private BigDecimal amount;
@Size(max=60)
private Collection<InvoiceDetail> details;
...
}
@Size or @Length or whatever else, but not a different annotation for each type.
In this way the class is easier to write and to read, is it ?
This constraint can be implemented using 'Polymorphic constraints':
http://forum.hibernate.org/viewtopic.php?t=985711
What do you think about this ?