我试一试,无法找到选项JPA>从实体生成表格。我来自eclipse世界,我可以通过几次点击生成实体或脚本,我发现在intellij中这很难做到。
这是我使用的persistence.xml:
<?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="hmdb" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/hmdb_dev"/>
<property name="javax.persistence.jdbc.user" value="appsetup"/>
<property name="javax.persistence.jdbc.password" value="--------"/>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
<property name="eclipselink.application-location" value="/home/jhonnytunes/Projects/hmdb/target" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql" />
</properties>
</persistence-unit>
</persistence>
我用来生成文件的位置是构思目录。是不是有办法使用您从eclipselink页面下载的eclipselink作为zip进行生成?
答案 0 :(得分:0)
您可以在服务器启动时使用persistence.xml生成DDL脚本:
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
<property name="eclipselink.application-location" value="/sql" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql" />
</properties>
第一个属性的值可以是
对于第二个属性