4
我想将我的Java应用程序部署到Heroku,我使用的是eclipse链接JPA。从eclipse链接创建数据库链接JPA实体
要做到这一点,我需要通过Java创建表,到目前为止我已经得到了下面的代码,但是如何获得DDL来创建表。我将在MySQL上运行应用程序进行开发,Heroku是Postgres for production。因此,我希望create table语句考虑到这一点。
import javax.persistence.*;
public class SchemaCreator
{
public static void main(String[] args)
{
EntityManagerFactory factory =
Persistence.createEntityManagerFactory("bitcoin");
EntityManager em = factory.createEntityManager();
String ddl = /// <--- How do I get it ?
em.createNativeQuery(ddl);
}
}
你想创建基于你的实体的数据库表或生成DDL查询来创建数据库(并在别处使用它)? –
http://stackoverflow.com/questions/779479/reverse-engineer-ddl-from-jpa-entities – madth3
我想能够创建表格形式的Java可执行文件。我不必手动编写SQL语句。 –