I've recently changed from using a direct JDBC connection to using a JBoss MySQL data souce on my configuration file. Despite having the hbm2ddl.auto="update" config on my hibernate.cfg.xml file the mapped tables (I'm using mapping xml files) are not generated automatically.
Once I switch back to a direct JDBC connection the tables are generated automatically. Am I missing something? I'd like to get the automatic table generation while using a data source.
Here's the relevant extract of my hibernate config.
Code:
<property name="connection.datasource">java:/MySqlDS</property>
<!-- JDBC CONNECTION POOL -->
<property name="hibernate.connection.pool_size">10</property>
<!-- ECHO ALL EXECUTED SQL -->
<property name="show_sql">true</property>
<!-- SQL DIALECT -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">jta</property>
<!-- OTHER SETTINGS available options are: validate | update | create | create-drop -->
<property name="hibernate.hbm2ddl.auto">update</property>
Here is my datasource extract:
Code:
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://(insert ip address)/test</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>user</user-name>
<password>pw</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
N.B. The above are only extracts, I've omitted irrelevant details. But I can assure you that they're just the basic setup from the documentations.