From lincolnbaxter at gmail.com Tue Sep 2 13:53:51 2014 From: lincolnbaxter at gmail.com (Lincoln Baxter, III) Date: Tue, 2 Sep 2014 13:53:51 -0400 Subject: [forge-users] How to use Forge 2 jpa-generate-entities-from-tables ? In-Reply-To: <6F35FE3C-A1D4-46A7-9A6F-44CB53BA8F3B@redhat.com> References: <699841680.01408560665550.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> <6F35FE3C-A1D4-46A7-9A6F-44CB53BA8F3B@redhat.com> Message-ID: 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 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 at 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. [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]$ > > > > Posted by forums > > Original post: https://community.jboss.org/message/901463#901463 > > > > _______________________________________________ > > forge-users mailing list > > forge-users at lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/forge-users > > _______________________________________________ > forge-users mailing list > forge-users at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/forge-users > -- Lincoln Baxter, III http://ocpsoft.org "Simpler is better." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/forge-users/attachments/20140902/6126d040/attachment.html From forge-users at lists.jboss.org Thu Sep 25 12:17:51 2014 From: forge-users at lists.jboss.org (forge-users at lists.jboss.org) Date: Thu, 25 Sep 2014 12:17:51 EDT Subject: [forge-users] How to use Forge 2.10.1.Final jpa-generate-entities-from-tables ? Message-ID: <1996507114.151411661901404.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> I'm using jboss developer studio 8 and trying to generate entities with forge 2.10.1.Final? and got the following error: ***ERROR*** Unable to make JDBC Connection [jdbc:mysql://localhost:3306/database] The url is the same as I have in the datasource for another project, I think I'm doing something wrong, these are the commands: project-new --named example_2 jpa-setup --provider Hibernate --dbType MYSQL5 --container WILDFLY --dataSourceName java:jboss/datasources/database jpa-generate-entities-from-tables --jdbcUrl jdbc:mysql://localhost:3306/database?characterEncoding=UTF-8 --userName user --userPassword password --driverLocation /home/user/mysql-connector-java-5.1.30-bin.jar In my datasource I have the following: ??????????????????? jdbc:mysql://localhost:3306/database?characterEncoding=UTF-8 ??????????????????? mysql-connector-java-5.1.30-bin ??????????????????? SELECT 1 ??????????????????? ??????????????????????? 15 ??????????????????????? 340 ??????????????????? ??????????????????? ??????????????????????? user ??????????????????????? password ??????????????????? ??????????????????? ??????????????????????? select 1 ??????????????????? ??????????????????? ??????????????????????? 10 ??????????????????? ? Try downloading the zip for GNU / Linux (Fedora 20) and gave the same error. And even when I pass as parameter --hibernateDialect gives me the menu to choose the dialect(org.hibernate.dialect.MySQL5Dialect , option zero). Any ideas? Excuse my English is bad. Posted by forums Original post: https://developer.jboss.org/message/905155#905155 From forge-users at lists.jboss.org Fri Sep 26 10:56:34 2014 From: forge-users at lists.jboss.org (forge-users at lists.jboss.org) Date: Fri, 26 Sep 2014 10:56:34 EDT Subject: [forge-users] How to use Forge 2.10.1.Final jpa-generate-entities-from-tables ? In-Reply-To: <1996507114.151411661901404.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> Message-ID: <1885149495.241411743424913.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> It looks like you are trying to use a MySQL database named 'database'.? Is that truly the name of your database ? Did you create your database tables as InnoDB tables ?? Unless you intend to not use transactions with hibernate, you will want to use InnoDB and that changes your database type from MYSQL5 to MYSQL5_INNODB.? Your hibernate dialect also must reflect InnoDB tables. Finally, your datasource seems unusual: the driver element looks like part of the jar file name rather than a java class name. My examples below are using jboss 7.1.1 so the dataSource name conforms to JEE6 JNDI conventions...Wildfly may use different conventions. Also, my example datasource file (par-ds.xml) may require changes for Wildfly.? These steps have been tested with forge 2.10.1.Final. These are the steps I follow to generate entities for all the tables in my 'par' database: 1. Create a new project named 'par': project-new --named par --topLevelPackage ca.gerrymatte.par --type war --finalName par ; 2. Install the jpa plug-in and specify in the persistence.xml that a datasource named parDS will be available when jboss/wildfly starts the webapp: jpa-setup --provider Hibernate --dbType MYSQL5_INNODB --container JBOSS_AS7 --dataSourceName java:jboss/datasources/parDS; 3. I choose to create a named connection so that I can be sure the database par is accessible from forge: connection-create-profile - --name parConnection --hibernateDialect org.hibernate.dialect.MySQL5InnoDBDialect --driverClass com.mysql.jdbc.Driver --driverLocation C:/s/jclasses/drivers/mysql.jar --userName root --userPassword xxxx --jdbcUrl jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull --verifyConnection true; 4. Generate JPA Entities for all tables using the connection profile: jpa-generate-entities-from-tables - --databaseTables * --connectionProfile parConnection --targetPackage ca.gerrymatte.par.model ; My par-ds.xml file contains: ??????????????? ??????????????????? jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull ??????????????????? mysql ??????????????????? TRANSACTION_READ_COMMITTED ??????????????????? ??????????????????????? 10 ??????????????????????? 20 ??????????????????????? false ??????????????????? ??????????????????? ??????????????????????? root ??????????????????????? xxxx ??????????????????? ??????????????????? ??????????????????????? 20 ??????????????????????? true ??????????????????? ??????????????? Posted by forums Original post: https://developer.jboss.org/message/905263#905263 From forge-users at lists.jboss.org Tue Sep 30 14:05:27 2014 From: forge-users at lists.jboss.org (forge-users at lists.jboss.org) Date: Tue, 30 Sep 2014 14:05:27 EDT Subject: [forge-users] Roaster: JavaClassSource to file Message-ID: <1082106887.341412100384302.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> Hi, I have started to use Roaster (standalone) to generate some java code. When you havea org.jboss.forge.roaster.model.source.JavaClassSource, what is the best way to write the content into a file? I could not find anything. How are other developers using Roaster? I came up with this method (based on google guava): public static void toFile(JavaClassSource javaClass, File srcFolder) throws IOException { ? File f = srcFolder; ? String[] parts = javaClass.getPackage().split("\\."); ? for (String n : parts) { ??? f = new File(f, n); ? } ? f = new File(f, javaClass.getName() + ".java"); ? Files.createParentDirs(f); ? Files.write(javaClass.toString(), f, Charsets.UTF_8); } Posted by forums Original post: https://developer.jboss.org/message/905590#905590 From ggastald at redhat.com Tue Sep 30 15:20:34 2014 From: ggastald at redhat.com (George Gastaldi) Date: Tue, 30 Sep 2014 15:20:34 -0400 (EDT) Subject: [forge-users] Roaster: JavaClassSource to file In-Reply-To: <1082106887.341412100384302.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> References: <1082106887.341412100384302.JavaMail.jive@jive-app01.app.mwc.hst.phx2.redhat.com> Message-ID: <3DE0375F-6692-4D77-A858-2D6689894B02@redhat.com> The best way is to call the toString() method and save it to a file > Em 30/09/2014, ?s 11:06, forge-users at lists.jboss.org escreveu: > > Hi, > > I have started to use Roaster (standalone) to generate some java code. > > When you havea org.jboss.forge.roaster.model.source.JavaClassSource, what is the best way to write the content into a file? > > I could not find anything. How are other developers using Roaster? > > I came up with this method (based on google guava): > > public static void toFile(JavaClassSource javaClass, File srcFolder) throws IOException { > File f = srcFolder; > String[] parts = javaClass.getPackage().split("\\."); > for (String n : parts) { > f = new File(f, n); > } > f = new File(f, javaClass.getName() + ".java"); > Files.createParentDirs(f); > Files.write(javaClass.toString(), f, Charsets.UTF_8); > } > > Posted by forums > Original post: https://developer.jboss.org/message/905590#905590 > > _______________________________________________ > forge-users mailing list > forge-users at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/forge-users