Pergunta

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 ?

Foi útil?

Solução

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.

Outras dicas

  <property name="show_sql">true</property>

In hibernate config

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top