Reputation: 2089
I started JPA 2.1 with Hibernate, and had the following lines in my persistence.xml
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="META-INF/sampleCreate.ddl"/>
<property name="javax.persistence.schema-generation.scripts.drop-target" value="META-INF/sampleDrop.ddl"/>
The tables are generated into my postgres DB.
However, there is no sampleCreate.dll in my META-INF folder, nor error.
What is missing here? Is it generated to other folder?
Thanks.
Upvotes: 5
Views: 3258
Reputation: 11267
Based on my tests, the files are created relative to your CWD (current working directory).
You can see this by doing something like this to print or log the System.getProperty("user.dir")
system property:
Getting the Current Working Directory in Java
I'm using maven, so if I do mvn test
with a path of create.ddl
my script gets created in the same directory I'm running maven from.
To find your current directory, either log or print the CWD and adjust your property values accordingly. You can also use relative paths, so if I wanted to put mine in the target/META-INF
directory I would use ./target/META-INF/create.ddl
since that is a valid directory relative to my CWD.
Upvotes: 1
Reputation: 330
So, I've found solution, it's not full solution.
But still.
First of all, I'm using Wildfly 10.1.0
I struggled with the same problem, I didn't saw my generated sql files.
But after some experiments I've found that, when Wildfly deploys my app, it generates sql files into it's bin directory (C:\wildfly\bin\
).
But I wanted to see them in my project source folder.
For this you should use ABSOLUTE PATH. Like this below (and it had worked for me):
<property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
<property name="javax.persistence.schema-generation.scripts.create-target" value="D:/myproject/src/resources/META-INF/sampleCreate.ddl"/>
<property name="javax.persistence.schema-generation.scripts.drop-target" value="D:/myproject/src/resources/META-INF/sampleDrop.ddl"/>
But this not convenient if you write code in command...
How it works with Glassfish, SpringBoot etc. I don't know, though I assume that like the same.
Upvotes: 4