0

JPA gurus, let say I have the following entity :

@Entity
class MyEntity {
    @Id
    private Long id;

    // setters and getters here
}

through JPA on an Oracle database something similar would be generated :

CREATE TABLE MyEntity {
    -- table definition generated by JPA provider goes here
}

How can I get the code generated by the JPA provider ?

If it's not possible to get the sql code in a standard way defined by JPA, how can I achieve this with Hibernate 3.6.8.Final or greater ?

Stephan
  • 41,764
  • 65
  • 238
  • 329
  • 1
    Note, that it's not the `JPA` duty to generate DDL. Some providers such as `Hiberhate` allow schema generation, some don't. Anyways, your question has nothing to do with JPA. – jFrenetic Feb 29 '12 at 17:30
  • You are right ... it's the JPA provider duty ! – Stephan Mar 01 '12 at 18:16
  • According to the JPA spec, `It is permitted, but not required, that DDL generation be supported by an implementation of this specification`. So your real question should probably sound more specific, like `How do I access the DDL generated by Hibernate from JPA entities?` – jFrenetic Mar 01 '12 at 18:52
  • I have updated the title to be clear. – Stephan Mar 01 '12 at 19:06

2 Answers2

1

Look at classes in hbm2ddl package

http://docs.jboss.org/hibernate/orm/3.6/javadocs/org/hibernate/tool/hbm2ddl/package-summary.html

Especially SchemaExport class.

František Hartman
  • 14,436
  • 2
  • 40
  • 60
0
  <property name="show_sql">true</property>

In hibernate config

NimChimpsky
  • 46,453
  • 60
  • 198
  • 311