2

Could you please let me know whether we have an option to generate ddl from entity class in intellij?

I could do the entity class generation from the table? I am looking to change the definition of a entity class and i need to re-generate the DDL for table?

I am using eclipse links for JPA.

Adam
  • 727
  • 4
  • 11
  • 21

1 Answers1

1

I would recommend to use eclipse link (not intellij) to create the ddl script.

With the ddl-generation.output-mode in persistence.xml you can instruct eclipse link to create an ddl script.

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0">
    <persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>        
        <properties>
...
            <property name="eclipselink.ddl-generation.output-mode" value="both"/>

            <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
            <property name="eclipselink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/>
            <property name="eclipselink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/>

        </properties>
    </persistence-unit>
</persistence>

@see:

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • I couldn't find any generated files. Links to Eclipse are useless. Can you please clarify step-by-step ? – alerya Sep 16 '16 at 06:08
  • @alery: first of all it is "Eclipse Link" not "Eclipse"! - But there are much more deteils needed to help you, so please write a new question (that describe your problem and what you have done so far, as well as the name and version of JPA Provider you use (Hibernate/EclipseLink./...) - If you want me to notice the question, then add an comment below this one that point at your question. – Ralph Sep 16 '16 at 07:09