-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Schema scripts not generated
PostPosted: Thu Apr 14, 2016 11:58 am 
Newbie

Joined: Tue Nov 24, 2015 3:52 pm
Posts: 12
Hi,

I have the following persistence.xml file, but I do not found any create.ddl or drop.ddl file in my computer after deployment. Any idea ?

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

   <persistence-unit name="primary">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>

      <properties>

         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

         <!-- create | drop the database -->
         <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />

         <!-- which scripts the persistence provider shall create -->
         <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create" />

         <!-- How the schema shall be created metadata | script | ... -->
         <property name="javax.persistence.schema-generation.create-source" value="metadata" />

         <!-- How the schema shall be dropped metadata | script | ... -->
         <property name="javax.persistence.schema-generation.drop-source" value="metadata" />

         <!-- Create the required database schemas true | false -->
         <property name="javax.persistence.schema-generation.create-database-schemas" value="true" />

         <!-- <property name="javax.persistence.schema-generation-target" value="database"/> -->

         <!-- for script generation -->
         <property name="javax.persistence.schema-generation-target" value="database-and-scripts" />
         <property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl" />
         <property name="javax.persistence.schema-generation.scripts.drop-target" value="drop.ddl" />

         <!-- Populate the database -->
         <property name="javax.persistence.sql-load-script-source" value="sql/load.sql" />
      </properties>

   </persistence-unit>

</persistence>


Top
 Profile  
 
 Post subject: Re: Schema scripts not generated
PostPosted: Fri Apr 15, 2016 2:18 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try with fewer options as indicated in [url=https://antoniogoncalves.org/2014/12/11/generating-database-schemas-with-jpa-2-1/this post[/url]:

Code:
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl" />
<property name="javax.persistence.schema-generation.scripts.drop-target" value="drop.ddl" />
<property name="javax.persistence.schema-generation.create-database-schemas" value="true" />


I couldn't find this property on th3 JPA spec:

Code:
<property name="javax.persistence.schema-generation-target" value="database-and-scripts" />


Top
 Profile  
 
 Post subject: Re: Schema scripts not generated
PostPosted: Mon Apr 18, 2016 3:06 am 
Newbie

Joined: Tue Nov 24, 2015 3:52 pm
Posts: 12
I've tried with those properties but still have same pb, the ddl files are not generated.
This is the updated persistence.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/persistence
        http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

   <persistence-unit name="primary">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>

      <properties>

         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />

         <!-- create | drop the database -->
         <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />

         <!-- which scripts the persistence provider shall create -->
         <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create" />

         <!-- How the schema shall be created metadata | script | ... -->
<!--          <property name="javax.persistence.schema-generation.create-source" value="${schema-generation.create-source}" /> -->

         <!-- How the schema shall be dropped metadata | script | ... -->
<!--          <property name="javax.persistence.schema-generation.drop-source" value="${schema-generation.drop-source}" /> -->

         <!-- Create the required database schemas true | false -->
         <property name="javax.persistence.schema-generation.create-database-schemas" value="true" />

         <!-- <property name="javax.persistence.schema-generation-target" value="database"/> -->

         <!-- for script generation -->
<!--          <property name="javax.persistence.schema-generation-target" value="${schema-generation-target}" /> -->
         <property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl" />
         <property name="javax.persistence.schema-generation.scripts.drop-target" value="drop.ddl" />

         <!-- Populate the database -->
         <property name="javax.persistence.sql-load-script-source" value="sql/load.sql" />
      </properties>

   </persistence-unit>

</persistence>


I run the mvn command:
Code:
mvn clean wildfly:deploy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.