Announcement Announcement Module
No announcement yet.
Getting "validation failed for classes" integration test exception when setting @Size Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting "validation failed for classes" integration test exception when setting @Size

    I'm using Roo 1.1.0.M3 with MYSQL and HIBERNATE. As soon as I set @Size on Strings on certain entities, I get this error:

    javax.validation.ConstraintViolationException: validation failed for classes [...] during persist time for groups [javax.validation.groups.Default, ]
    at org.hibernate.cfg.beanvalidation.BeanValidationEve ntListener.validate(BeanValidationEventListener.ja va:132)
    at org.hibernate.cfg.beanvalidation.BeanValidationEve ntListener.onPreInsert(BeanValidationEventListener .java:71)
    at eInsert(
    at org.hibernate.action.EntityIdentityInsertAction.ex ecute(

    Searching the bug database only results in an issue where this is a problem with an @Transient field. My entities have no transient fields though:

    @Column(name = "DISCOUNT_TYPE")
    @Size(max = 20)
    private String discountType;

    I'm thinking of abandoning Roo altogether due to the sheer number of problems I've run in to, both like this and with the DBRE feature (which ignores column size constraints when generating entities).

  • #2
    Can you expand on what operation you are performing when you get that exception? Was this a project created with Roo 1.1.0.RELEASE?

    If you try Roo 1.1.0.RELEASE and in an empty directory load Roo, type "script vote.roo", then quit and run "mvn test" and "mvn tomcat:run" you will see it works with a Hibernate-based @Size(max = 80) annotation on the Choice.description field. The clinic.roo sample also uses @Size and works fine. As such I'm not sure this is really a Roo problem, but I'm happy to try to help you sort it out.


    • #3
      Column sizes (eg @Column(name = "foo" length = "100") are actually brought back for String fields in DBRE with lengths up to 4000 characters. If I don't put this restriction on, some database metadata objects return lengths of Integer.MAX if the size is not specified on the actual column.