James Sutherland wrote:This depends on which JPA provider you are using. The JPA does not define auto schema creation.
For EclipseLink you set the persistence.xml property,
"eclipselink.ddl-generation"="create-tables"
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="DefaultDS" transaction-type="JTA">
<jta-data-source>java:/DefaultDS</jta-data-source>
<class>com.ernst.persistenceImpl.beanImpl.ArtikelBean</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/lagerstandnew"/>
<property name="hibernate.connection.username" value="raja"/>
<property name="hibernate.connection.password" value="sekhar"/>
<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JDBCTransactionFactory"/>
<!-- SQL stdout logging -->
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.show_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
</properties>
</persistence-unit>
</persistence>
Imran Perwez wrote:Try changing...
To...
See if that helps...
Imran Perwez wrote:Maybe a silly question... but I take it you are using JPA entities that are correctly annotated? And, not the old style EJB2.1 entity bean?
I don't have the issue you have. I have quite a minimalistic persistence.xml file and datasource compared to yours...
peristence.xml...
Datasource in "<jboss>\server\default\deploy"...
for your quick view this is my entity bean
Paul Sturrock wrote:
for your quick view this is my entity bean
Entity Beans are an EJB 2 technology. It confuses the issue if you use the term to refer to JPA classes.
Imran Perwez wrote:I think it's your transaction strategy that is causing the problem
Have you tried using a different transaction strategy?
Imran Perwez wrote:What was the exception?...
Paul Sturrock wrote:Transactions are unlikely to be the problem I think - DDL is (usually) not transactional.
Your configuration refers to something called ArtikelBean, which is not your annotated class. My guess is ArtikelBean does not contain annotations hbm2ddl can use. Can we see the class ArtikelBean, if that is indeed what you are trying to map? I see you have hibernate.archive.autodetection set too, could it be your mapped class is not deployed where you think it is?
Paul Sturrock wrote:My guess is you are either using an old version of persistence.xml. Hibernate seems to be reporting it creates a schema without any exceptions occurring, which makes me think your annotated class is not being found.
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="LagerstandnewDS" transaction-type="JTA">
<jta-data-source>java:/LagerstandnewDS</jta-data-source>
<class>com.ernst.persistenceImpl.beanImpl.NrKreiseBean</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/lagerstandnew;create=true"/>
<property name="javax.persistence.jdbc.user" value="raja"/>
<property name="javax.persistence.jdbc.password" value="sekhar"/> -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/lagerstandnew"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="sekhar"/>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
Paul Sturrock wrote:Is that valid XML? You have a trailing comment.
Imran Perwez wrote:This bit, end of line...
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="LagerstandnewDS" transaction-type="JTA">
<jta-data-source>java:/LagerstandnewDS</jta-data-source>
<class>com.ernst.persistenceImpl.beanImpl.NrKreiseBean</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/lagerstandnew"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="sekhar"/>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.id.new_generator_mappings" value="true"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.use_structured_entries" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.show_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
</properties>
</persistence-unit>
</persistence>
I'm not sure if I approve of this interruption. But this tiny ad checks out:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|