Announcement Announcement Module
Collapse
No announcement yet.
Integration test causing a duplicate entry exception on insert Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hi Alan,

    Some feedback for info only.

    I ran my script:

    script /home/stephane/dev/help/learnintouch.roo

    but got the following message:

    jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
    Created core|ROOT/src/main/resources/META-INF/spring/database.properties
    Updated core|ROOT/src/main/resources/META-INF/spring/applicationContext.xml
    Created core|ROOT/src/main/resources/META-INF/persistence.xml
    Updated core|ROOT/pom.xml [added dependencies org.hsqldb:hsqldb:1.8.0.10, org.hibernate:hibernate-core:3.6.9.Final, org.hibernate:hibernate-entitymanager:3.6.9.Final, org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final, org.hibernate:hibernate-validator:4.2.0.Final, javax.validation:validation-api:1.0.0.GA, cglib:cglib-nodep:2.2.2, javax.transaction:jta:1.1, org.springframework:spring-jdbc:${spring.version}, org.springframework:spring-orm:${spring.version}, commons-pool:commons-pool:1.5.6, commons-dbcp:commons-dbcp:1.3]
    database properties list
    database.driverClassName = org.hsqldb.jdbcDriver
    database.password =
    database.url = jdbc:hsqldb:mem:core
    database.username = sa
    database properties set --key database.username --value learnintouch
    Updated core|ROOT/src/main/resources/META-INF/spring/database.properties
    database properties set --key database.password --value xxxxxxxx
    Updated core|ROOT/src/main/resources/META-INF/spring/database.properties
    database properties set --key database.url --value jdbc:hsqldb:mem:db_integration
    Updated core|ROOT/src/main/resources/META-INF/spring/database.properties
    database properties list
    database.driverClassName = org.hsqldb.jdbcDriver
    database.password = mignet
    database.url = jdbc:hsqldb:mem:db_integration
    database.username = learnintouch
    database introspect --schema db_integration
    addon search --requiresDescription "#jdbcdriver,driverclass:org.hsqldb.jdbcDriver " found no matches
    JDBC driver not available for 'org.hsqldb.jdbcDriver'
    Script required 6.363 seconds to execute
    Script execution aborted
    Last edited by stephaneeybert; Apr 12th, 2012, 03:07 PM.

    Comment


    • #17
      I think the campari is not helping..

      So I started over, this time not from an empty directory, but from my existing project directory and ll its already generated content.

      In there I ran the command:

      jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

      which answered me with:

      additionalBuildCommands element of the maven-eclipse-plugin required
      Last edited by stephaneeybert; Apr 12th, 2012, 03:26 PM.

      Comment


      • #18
        I think I was meesing up with the types of packing, too many pom types lying around, I fixed that up.

        I then ran the command:

        data roo> jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
        Updated data|SPRING_CONFIG_ROOT/database.properties
        Updated data|SPRING_CONFIG_ROOT/applicationContext.xml
        Updated data|SRC_MAIN_RESOURCES/META-INF/persistence.xml
        Updated data|ROOT/pom.xml [added dependency org.hsqldb:hsqldb:1.8.0.10; skipped dependencies org.hibernate:hibernate-core:3.6.9.Final, org.hibernate:hibernate-entitymanager:3.6.9.Final, org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final, org.hibernate:hibernate-validator:4.2.0.Final, javax.validation:validation-api:1.0.0.GA, cglib:cglib-nodep:2.2.2, javax.transaction:jta:1.1, org.springframework:spring-jdbc:${spring.version}, org.springframework:spring-orm:${spring.version}, commons-pool:commons-pool:1.5.6, commons-dbcp:commons-dbcp:1.3; removed dependency mysql:mysql-connector-java:5.1.18]
        data roo>

        I also set a create in the hibernate.hbm2ddl.auto property.

        I ran the command:

        database properties set --key database.url --value jdbc:hsqldb:mem:db_integration

        Then I ran the tests:

        perform tests

        But it said the tables were not found:

        Caused by: java.sql.SQLException: Table not found in statement [select top ? mail0_.id as id63_, ma
        il0_.admin_id as admin11_63_, mail0_.attachments as attachme2_63_, mail0_.body as body63_, mail0_.c
        ategory_id as category12_63_, mail0_.creation_datetime as creation4_63_, mail0_.description as desc
        ript5_63_, mail0_.locked as locked63_, mail0_.send_datetime as send7_63_, mail0_.subject as subject
        63_, mail0_.text_format as text9_63_, mail0_.version as version63_ from mail mail0_]

        I would think it is a user priviledge issue with the table object not granted access to.

        I'll try with the user sa and empty password.
        Last edited by stephaneeybert; Apr 13th, 2012, 03:12 PM.

        Comment


        • #19
          So I set up the sa user and his empty password:

          data roo> database properties list
          database.driverClassName = org.hsqldb.jdbcDriver
          database.password =
          database.url = jdbc:hsqldb:mem:data
          database.username = sa

          But I still get the same exception:

          Caused by: java.sql.SQLException: Table not found in statement [select top ? mail0_.id as id20_, ma
          il0_.admin_id as admin11_20_, mail0_.attachments as attachme2_20_, mail0_.body as body20_, mail0_.c
          ategory_id as category12_20_, mail0_.creation_datetime as creation4_20_, mail0_.description as desc
          ript5_20_, mail0_.locked as locked20_, mail0_.send_datetime as send7_20_, mail0_.subject as subject
          20_, mail0_.text_format as text9_20_, mail0_.version as version20_ from mail mail0_]

          Comment


          • #20
            This is outside the realm of Roo now - probably best to search the Hibernate forum at jboss.org

            Comment


            • #21
              So I posted on the Hibernate Forum, this time using the HSQLDB file type instead of mem as it shows more in the log.

              https://forum.hibernate.org/viewtopic.php?f=1&t=1015149

              I still wonder if the Spring Roo setup of

              <property name="hibernate.hbm2ddl.auto" value="create"/>

              in the persistence.xml file is really being used as the HSQLDB log shows all these drop if exists statements.
              Last edited by stephaneeybert; Apr 14th, 2012, 03:08 AM.

              Comment


              • #22
                I wonder why wanting to try running the integration test in HSQLDB instead of MySql.

                Would that give more information on the cause of the original unique attribute not being seen by Roo ?

                Comment


                • #23
                  This time the process of performing the test is very slow.

                  The log of hsqldb shows the following output:

                  /*C167*/SET SCHEMA PUBLIC
                  CONNECT USER SA
                  DISCONNECT

                  It adds one such output entry every few minutes.

                  It feels like the perform test command could take the whole day (it is now running for at least half an hour).

                  Comment


                  • #24
                    I went back to trying with MySql again as my attempt at using hsqldb did not go very far.

                    When I run the tests from the shell with the command: mvn clean install

                    I get a lot of these in the console output:

                    [WARNING] this affected type is not exposed to the weaver: com.learnintouch.lms.data.domain.Sms [Xlint:typeNotExposedToWeaver]
                    [WARNING] this affected type is not exposed to the weaver: com.learnintouch.lms.data.domain.Sms [Xlint:typeNotExposedToWeaver]
                    [WARNING] this affected type is not exposed to the weaver: com.learnintouch.lms.data.domain.Sms [Xlint:typeNotExposedToWeaver]
                    [WARNING] this affected type is not exposed to the weaver: com.learnintouch.lms.data.domain.Sms [Xlint:typeNotExposedToWeaver]

                    In fact I get one for each each domain class.

                    And some 87 tests out of 1026 fail due to the fact that they have a unique constraint on a field that is not their primary id.

                    Here is again the exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityCons traintViolationException: Duplicate entry '2297' for key 'user_id_2'

                    Comment


                    • #25
                      So I tried the H2 database and all tests passed fine.

                      Tests run: 1026, Failures: 0, Errors: 0, Skipped: 0

                      No wonder, the unique constraint that exists in the MySql table structure does not exist in the Spring Roo generated java source code and therefore H2 is not botered by any of it.

                      Comment

                      Working...
                      X