Announcement Announcement Module
No announcement yet.
Integration Test Error - 1.1.0M1, STS 2.3.3M1, MySQL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Integration Test Error - 1.1.0M1, STS 2.3.3M1, MySQL

    Hi, I have found a problem with running tests from STS in M1 with MySQL and using a "field reference --notNull"

    Executing this script (with changing the db properties where needed) works fine
    // Spring Roo 1.1.0.M1 [rev 3a0b8a3] log opened at 2010-05-21 20:43:39
    project --topLevelPackage com.test --projectName Test
    persistence setup --provider HIBERNATE --database MYSQL 
    entity --class ~.Parent --testAutomatically 
    entity --class ~.Child --testAutomatically 
    field reference --fieldName parent --type com.test.Parent --notNull
    // Setup the file for the database 
    perform tests
    That ends up with a test ChildIntegrationTest ... running this through STS 2.3.3 this test fails with ....

    javax.validation.ConstraintViolationException: validation failed for classes [com.test.Child] during persist time for groups [javax.validation.groups.Default, ]
    	at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(
    	at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(
    	at org.hibernate.action.EntityIdentityInsertAction.preInsert(
    	at org.hibernate.action.EntityIdentityInsertAction.execute(
    	at org.hibernate.engine.ActionQueue.execute(

    And I traced this down through debugging .... to
    public Parent ParentDataOnDemand.getRandomParent() {
            Parent obj = data.get(rnd.nextInt(data.size()));
            return Parent.findParent(obj.getId());
    The get Parent.findParent call is returning null. And this is being called during the ChildDataOnDemand init method which then goes and tries to save the Child with a null parent which causes the validation exception.

    doing the "perform tests" command works ... its only running the test through eclipse.

    It also doesn't seem to happen with HyperSonic, I'm using innodb for the tables, and I tried changing the dialect for hibernate to the innodb one but still the same problem.

    I originally noticed this error trying to convert a project from 1.0.2 and have narrowed it down to this.

    Any ideas out there for a quick fix? and I'll raise a JIRA

  • #2
    I've got the same error for a basic entity (I mean, using plain fields, with not references fields, nor sets fields) and database HYPERSONIC_IN_MEMORY.

    In Roo 1.0.1 the same script works.

    project --topLevelPackage com.mycom.tablas
    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY 
    entity --class ~.domain.Provincia --table S1 --identifierColumn IDPROV
    field string --fieldName codigo --notNull --sizeMax 2    --type java.lang.String --column CODE
    field number --fieldName identificador --notNull  --type java.lang.Integer --column APRFN
    field number --fieldName telefono --notNull  --type java.lang.Integer --column TFNO
    field string --fieldName nombreReducido --notNull --sizeMax 15   --type java.lang.String --column REDU
    field string --fieldName nombre --notNull --sizeMax 40   --type java.lang.String --column NAME
    field number --fieldName comunidadAutonoma  --type java.lang.Integer --column CCAA
    test integration 
    controller scaffold ~.web.ProvinciaController
    Another script worked in 1.0.1. It has no number fields.

    I tried to change manually the X_DataOnDemand_Roo_DataOnDemand but it doesn't work. In fact, the random object seems to be created correctly.

    The exception is thrown when trying to persist the object randomly created: obj.persist(); (in X_DataOnDemand_Roo_DataOnDemand)


    • #3
      Would you please log a bug report at and we'll investigate.


      • #4
        Cheers Ben,

        Issue created


        • #5
          Thanks. We'll get to it shortly.


          • #6
            Any workaround??


            I need a workaround.
            Accualy I disabled the @NotNull to work, but I need it.


            • #7
              I'm not sure if I hit the same problem, but here the problem also occurs if I use standalone maven.
              The bug was set to fixed, but I'm not convinced this is an Eclipse problem...

              Steps to reproduce:
              I have changed persistence.xml to use org.hibernate.dialect.MySQLInnoDBDialect

              Since then, the integrationtests fail.


              • #8
                Yes im not convinced that its an eclipse issue anymore either. Some combination of things I have changed in my real project cause it to fail these tests in mvn as well. I never made it clear enough in the JIRA issue that it was happening outside eclipse.

                Are you saying that using the MySQLDialect worked and the MySQLInnoDBDialect didn't?
                Or did you only use the MySQLInnoDBDialect?

                Alan Stewart was talking to me after he closed the issue through the comments and the last thing I did was post the smallest possible example project that fails. Other than that im not sure what else to do about this ... my project is in a stage where I can survive without the @NotNull's where they should be, but going to have to find a solution soon (or remove a whole load of tests)


                • #9
                  Switching back to MySQLDialect didn't help.
                  I then debugged the tests and figured out, that the tests do not take constraints into account.

                  Lets say you got that Entity field definition:
                  @Size(min = 3, max = 3)
                  private String codeDa;

                  The test tries to persist an entity with the following codeDA value:

                  This is a bug.
                  Maybe we should reopen the ticket...


                  • #10
                    I haven't forgotten you Steve about R00-873. I sent your zip to Christian (STS) to see if he can see a problem. I've been on DBRE (ROO-435) and haven't had time to investigate this further, however I am determined to find out what's causing the problem. FYI, I tried your project in native Eclipse 3.5 (64-bit) running on 64-bit Ubuntu with JDK 1.6_20 and got the same problem. Also, I did a "push-in" refactor and still saw the behaviour. Yet, I still can't reproduce the problem on the command line, anyway I'll re-open the ticket

                    Last edited by Alan Stewart; Jun 25th, 2010, 07:10 AM.


                    • #11
                      Cool thanks Alan, Glad (in a way) that you can see the issue as well.

                      The @Size thing is a different beast and it is logged in