Hi,
Would it be a good or bad idea to create a org.hibernate.validator.annotation.BusinessKey annotation?
The goal is create a mean to use Entities in hash-based classes no matter the Entity is transient, detached or persistent.
So the use case: I have an "normal" entity with @Id, @OneToMany aso.
I add..
@BusinessKey
String email;
...to the email and possibly to several other fields. And then:
1) A unique constraint will be added in the DDL for those properties forming the business key
2) @PrePersist and @PreUpdate will verify the the business key is set
3) If build-time bytecode instrumentation has been used, the equals and hashcode methods will be enhanced to use the business key in the comparison.
Then, hopefully, I'd be able to use my entities in any hash-based collection regardless of the state? Or is there a more clever way to achieve this declaratively?
br,
Jens
|