Hi all,

i've just submitted a patch to add bean validation stuff to OpenEJB (
https://issues.apache.org/jira/secure/attachment/12476731/bean-validation-4.0.0-r1094584.patch
).

It adds Validator and ValidatorFactory to java:comp (like specified in the
spec) but in java:openejb/ValidatorFactory/
<moduleId> and java:openejb/Validator/<moduleId> too to help internal
lookups.

A validatorfactory "proxy" is set in the map used to create the
entitymanager (key = javax.persistence.validator.ValidatorFactory) so it
allows to use it in jpa entities:). This proxy aims to allow to the same
entitymanager in a single transaction (it avoids to create an entitymanager
by validatorfactory).

Finally i put in the javax.faces.validator.beanValidator.ValidatorFactory
attribute of the servlet context in TomEE mode the validator factory too to
use it with jsf (i'm far to be an expert of this domain so don't feel shy to
hack it).

example on an entity:

    @Entity
    public static class EntityToValidate {
        @Id @GeneratedValue private long id;
        @NotNull @Size(min = 1, max = 5) private String name;

        // getters/setters
    }

-> name attribute will be validated during jpa hooks (prepersist, for
example)

- Romain Manni-Bucau

Reply via email to