jpa bean validation is not working - I can persist objects with
properties not satisfying constraints.

I use archetype from 
http://dmakariev.blogspot.com/2010/01/jsf-20-with-spring-3-and-spring.html
It does correctly as written here:
http://www.datanucleus.org/products/accessplatform_3_0/jpa/bean_validation.html

pom.xml:
                <!-- Bean Validation API (JSR 303) -->
                <dependency>
                        <groupId>javax.validation</groupId>
                        <artifactId>validation-api</artifactId>
                        <version>1.0.0.GA</version>
                </dependency>
                <!-- Bean Validation Implementation -->
                <!-- Provides portable constraints such as @NotEmpty, @Email and
@Url -->
                <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-validator</artifactId>
                        <version>4.0.2.GA</version>
                        <exclusions>
                                <exclusion>
                                        <artifactId>jaxb-api</artifactId>
                                        <groupId>javax.xml.bind</groupId>
                                </exclusion>
                                <exclusion>
                                        <artifactId>jaxb-impl</artifactId>
                                        <groupId>com.sun.xml.bind</groupId>
                                </exclusion>
                        </exclusions>
                </dependency>

property is

        @Basic
        @NotNull
        @Size(min=3, max=7)
        private String ownerName;

I can persist null ownerName, and with length 2 and 8

I also tried adding to persistence.xml
<properties>
    <property name="javax.persistence.validation.mode" value="auto"/>

(it is default anyway)

--
when I tried calling validation manually:

ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
                Validator  validator = factory.getValidator();

                Set<ConstraintViolation<Gallery>> constraintViolations =
            validator.validate(gallery);

constraintsViolations are successfully present. (but no errors are
thrown further by jpa)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to