[forge-issues] [JBoss JIRA] (FORGE-1686) Not setting up a provider in JPA doesn't add properties in persistence.xml

Antonio Goncalves (JIRA) issues at jboss.org
Wed Mar 19 10:44:11 EDT 2014


Antonio Goncalves created FORGE-1686:
----------------------------------------

             Summary: Not setting up a provider in JPA doesn't add properties in persistence.xml
                 Key: FORGE-1686
                 URL: https://issues.jboss.org/browse/FORGE-1686
             Project: Forge
          Issue Type: Bug
          Components: Java EE
    Affects Versions: 2.2.0.Final
            Reporter: Antonio Goncalves
            Priority: Critical
             Fix For: 2.x Future


If you create a project with a few entities and then scaffold a JSF front end without setting up jpa (command {{jpa-setup}}), the generated {{persistence.xml}} looks like this :

{code}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="test-persistence-unit" transaction-type="JTA">
  <description>Forge Persistence Unit</description>
    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
  </persistence-unit>
</persistence>
{code}

In the {{pom.xml}}, the Hibernate dependency has been added, so it's like Hibernate is the default.... but not Hibernate properties... so, unfortunattelly, the webapp doesn't work. Once deployed on JBoss it cannot create the tables... because there are some properties missing. If you run {{jpa-setup --provider Hibernate}}, then you have what you need :

{code}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="test-persistence-unit" transaction-type="JTA">
    <description>Forge Persistence Unit</description>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.format_sql" value="true"/>
      <property name="hibernate.transaction.flush_before_completion" value="true"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>
{code}

On one hand, Hibernate has been added to the pom, and on the other hand it hasn't beed added in the persistence.xml... So, by default, not executing {{jpa-setup}} should be equivalent as executing {{jpa-setup --provider Hibernate}}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the forge-issues mailing list