1 Reply Latest reply on Mar 29, 2008 3:58 PM by Pete Muir

    EntityHome, dynamic proxy-wrapped entity instance and annotation-driven validation

    Thanassis Stathopoulos Newbie


      I am considering an EntityHome extension pattern where I wrap the EntityHome-managed internal entity instance to a dynamic proxy inner class and return this from getInstance().

      The intent is to intercept any calls made to the entity's property setters so I can automatically provide for annotation-driven validation at the model level; things like preemptively checking for unique values, inferring and enforcing constraints from @Column annotations  etc. The dynamic proxy wrapper will have access to the persistence manager within EntityHome, which facilitates this kind of checks. I understand that Web Validation etc will offer a standard DRY alternative but I need something now, and this approach appears interesting on first thought.

      Question to Seam experts: does this approach violate any apparent Seam architectural assumptions that evade me? I can see some ground for conflict with Hibernate validators if such are defined on the entity, but probably these can be worked around.

      TIA for any an all pointers.