AppFuse
  1. AppFuse
  2. APF-1258

appfuse:gen generates badly formatted data in sample-data.xml for @Version persistence fields

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.2.1
    • Component/s: Tools - AppGen
    • Labels:
      None
    • Environment:
      multi-module archetype, Struts2

      Description

      When a bean has a @Version annotation, the generated test data in sample-data.xml is badly formatted throwing and exception in dbunit

        Activity

        Hide
        Matt Raible added a comment -

        Please provide example of how to reproduce.

        Show
        Matt Raible added a comment - Please provide example of how to reproduce.
        Hide
        J. Garcia added a comment -

        Add a model class:

        @Entity
        @Table(name="document")
        @Indexed
        public class Document implements Serializable {
        
            private static final long serialVersionUID = -9102286295950214586L;
        
            private Long id;
            private String name;
            private Integer copies;
            private Double price;
            private Date releaseDate;
            private Date updated;
            private Integer version;
        
            @Version
            public Integer getVersion() {
                return version;
            }
            public void setVersion(Integer version) {
                this.version = version;
            }
        ...
        }
        

        Generate code:

            appfuse:gen -Dentity=Document

        Run:

            mvn jetty:run -e

        You get:

        [INFO] Trace
        org.apache.maven.lifecycle.LifecycleExecutionException: Error executing database operation: CLEAN_INSERT
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1205)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1038)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:643)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
                at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
                at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
                at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
                at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
                at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
                at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
                at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
        Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing database operation: CLEAN_INSERT
                at org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:109)
                at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
                at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
                ... 21 more
        Caused by: org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'document' and column 'version'
                at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190)
                at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
                at org.dbunit.operation.TransactionOperation.execute(TransactionOperation.java:78)
                at org.dbunit.ant.Operation.execute(Operation.java:195)
                at org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:100)
                ... 23 more
        Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <                1> of type <java.lang.String
        > to INTEGER
                at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:74)
                at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:99)
                at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73)
                at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63)
                at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186)
                ... 27 more
        Caused by: java.lang.NumberFormatException
                at java.math.BigDecimal.<init>(BigDecimal.java:459)
                at java.math.BigDecimal.<init>(BigDecimal.java:728)
                at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:70)
                ... 31 more
        
        Show
        J. Garcia added a comment - Add a model class: @Entity @Table(name= "document" ) @Indexed public class Document implements Serializable { private static final long serialVersionUID = -9102286295950214586L; private Long id; private String name; private Integer copies; private Double price; private Date releaseDate; private Date updated; private Integer version; @Version public Integer getVersion() { return version; } public void setVersion( Integer version) { this .version = version; } ... } Generate code: appfuse:gen -Dentity=Document Run: mvn jetty:run -e You get: [INFO] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Error executing database operation: CLEAN_INSERT at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1205) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1038) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:643) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing database operation: CLEAN_INSERT at org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:109) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) ... 21 more Caused by: org.dbunit.dataset.datatype.TypeCastException: Error casting value for table 'document' and column 'version' at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:190) at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79) at org.dbunit.operation.TransactionOperation.execute(TransactionOperation.java:78) at org.dbunit.ant.Operation.execute(Operation.java:195) at org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:100) ... 23 more Caused by: org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value < 1> of type <java.lang. String > to INTEGER at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:74) at org.dbunit.dataset.datatype.IntegerDataType.setSqlValue(IntegerDataType.java:99) at org.dbunit.database.statement.SimplePreparedStatement.addValue(SimplePreparedStatement.java:73) at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addValue(AutomaticPreparedBatchStatement.java:63) at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:186) ... 27 more Caused by: java.lang.NumberFormatException at java.math.BigDecimal.<init>(BigDecimal.java:459) at java.math.BigDecimal.<init>(BigDecimal.java:728) at org.dbunit.dataset.datatype.IntegerDataType.typeCast(IntegerDataType.java:70) ... 31 more
        Show
        J. Garcia added a comment - Fixed with: https://github.com/appfuse/appfuse/commit/7eb822b62ca9341446bb7d17ffe693276ff2c7a9

          People

          • Assignee:
            J. Garcia
            Reporter:
            J. Garcia
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development