6 Replies Latest reply on Sep 2, 2014 1:53 PM by Lincoln Baxter III

    How to use Forge 2 jpa-generate-entities-from-tables ?

    Gerry Matte Apprentice

      I have been trying to develop a standard way to generate my webapps from a MySQL5 database schema using Forge 2.7.2.Final on Windows 7/Oracle Java 1.7.0_67.

      I am creating a text file that contains the commands needed to generate the webapp using Forge from a windows command line:

      project-new --named par --topLevelPackage ca.gerrymatte.par --type war --finalName par ;


      jpa-setup --provider Hibernate --dbType MYSQL5_INNODB --container JBOSS_AS7 --dataSourceName java:jboss/datasources/parDS ;


      jpa-generate-entities-from-tables - --targetPackage ca.gerrymatte.par.model --hibernateDialect MySQL5\ with\ InnoDB\ :\ org.hibernate.dialect.MySQL5InnoDBDialect --driverClass com.mysql.jdbc.Driver --driverLocation C:/s/jclasses/drivers/mysql.jar --userName root --userPassword **** --jdbcUrl jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull ;

       

      The third command fails with an uninfomative error:

      log4j:WARN No appenders could be found for logger (org.jboss.forge.addon.database.tools.generate.DatabaseTableSelectionStep$2).

      log4j:WARN Please initialize the log4j system properly.

      [par]$

       

      Can anyone suggest how to resolve this ?

        • 1. Re: How to use Forge 2 jpa-generate-entities-from-tables ?
          Gerry Matte Apprentice

          Or post an example of using this command with any type of database server ?

          • 2. Re: How to use Forge 2 jpa-generate-entities-from-tables ?
            Gerry Matte Apprentice

            The problem has been fixed with version 2.8.0.Final.

            Using the above commands now generates a loop allowing me to select from a list of tables.  Once selected, the table is removed from the list and the list redisplays until I enter nothing (hit return only).  The entities are then generated.  The man page for  jpa-generate-entities-from-tables only documents the targetPackage parameter (I guessed the remaining parameters from other commands).

             

            Is there a parameter that will automatically select all tables from the specified database schema ?

             

            To whomever fixed this bug, thank you very much !

             

            Below is an example of the output of jpa-generate-entities-from-tables:

            jpa-generate-entities-from-tables - --targetPackage ca.gerrymatte.par.model --hibernateDialect MySQL5\ with\ InnoDB\ :\ org.hibernate.dialect.MySQL5InnoDBDialect --driverC lass com.mysql.jdbc.Driver --driverLocation C:/s/jclasses/drivers/mysql.jar --userName root --userPassword xxxxx --jdbcUrl jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults= UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull ;

             

            log4j:WARN No appenders could be found for logger (org.hibernate.cfg.reveng.dialect.MySQLMetaDataDialect). log4j:WARN Please initialize the log4j system properly.

            [0] - activities

            [1] - clients

            [2] - companies

            [3] - daybook

            [4] - loglines

            [5] - logsessions

            [6] - people

            [7] - roles

            [8] - staff

            [9] - timeservices

            [10] - timesheetofficeonly

            Database Tables (The database tables for which to generate entities): [0-10] 6

             

            [0] - activities

            [1] - clients

            [2] - companies

            [3] - daybook

            [4] - loglines

            [5] - logsessions

            [6] - roles

            [7] - staff

            [8] - timeservices

            [9] - timesheetofficeonly

            Database Tables (The database tables for which to generate entities): [0-9] 6

             

            [0] - activities

            [1] - clients

            [2] - companies

            [3] - daybook

            [4] - loglines

            [5] - logsessions

            [6] - staff

            [7] - timeservices

            [8] - timesheetofficeonly

            Database Tables (The database tables for which to generate entities): [0-8]

             

            ***SUCCESS*** 2 entities were generated in ca.gerrymatte.par.model

            [persistence.xml]$

            • 3. Re: [forge-users] How to use Forge      2     jpa-generate-entities-from-tables ?
              George Gastaldi Master

              Hi Gerry,

               

              I am glad it works for you now. Have you tried using "*"? If that still doesn't work, please open a JIRA and we'll have a look at it asap.

               

              Best Regards,

               

              George Gastaldi

              • 4. Re: How to use Forge 2 jpa-generate-entities-from-tables ?
                Rodney Kirkpatrick Newbie

                How do I get Forge 2.8.0 in my copy of JBoss Developer Studio

                Version: 8.0.0.Beta3

                Build id: Beta3-v20140722-2011-B194

                Build date: 20140722-2011

                 

                Right now I have 2.7.2 and 1.4.4 runtimes. I'm new to this and I'm currently attempting the following (below) - but no entities are generated and no ERRORS are shown.  I'm wonder if 2.8.0 will resolve my issue.

                jpa-generate-entities-from-tables \

                --hibernateDialect MySQL5\ with\ InnoDB\ :\ org.hibernate.dialect.MySQL5InnoDBDialect \

                --jdbcUrl jdbc:mysql://localhost:3306/tehub --userName root --userPassword mariadb \

                --driverClass com.mysql.jdbc.Driver --driverLocation C:\JBOSS\mysql-connector-java-5.1.32-bin.jar \

                --targetPackage com.hp.tehub.model

                 

                Any help would be wonderful

                rodney.kirkpatrick@hp.com

                • 5. Re: How to use Forge 2 jpa-generate-entities-from-tables ?
                  George Gastaldi Master

                  Hi Rodney,

                   

                  You can update to the latest version by using the nightly version:

                  Add the following URL to your Eclipse Luna 4.4 installation, via: Help > Install New Software… > Work with:

                  http://download.jboss.org/jbosstools/updates/nightly/luna/

                  Then select the Forge Tools component.

                   

                  Hope it helps!

                   

                  George Gastaldi

                  • 6. Re: [forge-users] How to use Forge 2 jpa-generate-entities-from-tables ?
                    Lincoln Baxter III Master

                    We should probably add "*" to the man page so that folks know they can

                    select a group of, or all, tables using the simple pattern.

                     

                     

                    On Wed, Aug 20, 2014 at 3:13 PM, George Gastaldi <ggastald@redhat.com>

                    wrote:

                     

                    Hi Gerry,

                     

                    I am glad it works for you know. Have you tried using "*"? If that still

                    doean't work, please open a JIRA and we'll have a look at it asap.

                     

                    Em 20/08/2014, às 15:51, forge-users@lists.jboss.org escreveu:

                     

                    The problem has been fixed with version 2.8.0.Final.

                    Using the above commands now generates a loop allowing me to select from

                    a list of tables.  Once selected, the table is removed from the list and

                    the list redisplays until I enter nothing (hit return only).  The entities

                    are then generated.  The man page for  jpa-generate-entities-from-tables

                    only documents the targetPackage parameter (I guessed the remaining

                    parameters from other commands).

                     

                    Is there a parameter that will automatically select all tables from the

                    specified database schema ?

                     

                    Below is an example of the output of jpa-generate-entities-from-tables:

                    jpa-generate-entities-from-tables - --targetPackage

                    ca.gerrymatte.par.model --hibernateDialect MySQL5\ with\ InnoDB\ :\

                    org.hibernate.dialect.MySQL5InnoDBDialect --driverC lass

                    com.mysql.jdbc.Driver --driverLocation C:/s/jclasses/drivers/mysql.jar

                    --userName root --userPassword matteg --jdbcUrl

                    jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults=

                    UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull ; log4j:WARN No

                    appenders could be found for logger

                    (org.hibernate.cfg.reveng.dialect.MySQLMetaDataDialect). log4j:WARN Please

                    initialize the log4j system properly. - activities - clients -

                    companies - daybook - loglines - logsessions - people -

                    roles - staff - timeservices - timesheetofficeonly Database

                    Tables (The database tables for which to generate entities): 6 -

                    activities - clients - companies - daybook - loglines -

                    logsessions - roles - staff - timeservices -

                    timesheetofficeonly Database Tables (The database tables for which to

                    generate entities): 6 - activities - clients - companies

                    - daybook - loglines - logsessions - staff -

                    timeservices - timesheetofficeonly Database Tables (The database tables

                    for which to generate entities): **SUCCESS** 2 entities were

                    generated in ca.gerrymatte.par.model $

                     

                    Posted by forums

                    Original post: https://community.jboss.org/message/901463#901463

                     

                    _______________________________________________

                    forge-users mailing list

                    forge-users@lists.jboss.org

                    https://lists.jboss.org/mailman/listinfo/forge-users

                     

                    _______________________________________________

                    forge-users mailing list

                    forge-users@lists.jboss.org

                    https://lists.jboss.org/mailman/listinfo/forge-users

                     

                     

                     

                     

                    --

                    Lincoln Baxter, III

                    http://ocpsoft.org

                    "Simpler is better."