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:
<?xml version="1.0" encoding="UTF-8"?>
<datasources
xmlns="http://www.jboss.org/ironjacamar/schema">
<datasource jta="true"
jndi-name="java:jboss/datasources/parDS" pool-name="parDS"
enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql:///par?characterEncoding=UTF-8&characterSetResults=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull</connection-url>
<driver>mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>false</prefill>
</pool>
<security>
<user-name>root</user-name>
<password>xxxx</password>
</security>
<statement>
<prepared-statement-cache-size>20</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
</datasources>
Posted by forums
Original post:
https://developer.jboss.org/message/905263#905263