I'm using hibernate annotations and i want to export my database schema.
Similar to the schemaexporttask with hbm xml files.
I'm using hibernate annotations and i want to export my database schema.
Similar to the schemaexporttask with hbm xml files.
Use hibernate3-maven-plugin. Then run 'mvn hibernate3:hbm2ddl'
You can. Just do it
Indeed, the original Hibernate Core
SchemaExportTask
can only handle Hibernate XML mapping files, not annotations. What you need is theHibernateToolTask
that comes with Hibernate Tools.Here is an Usage example adapted from Java Persistence With Hibernate:
See also
In case someone is interested how to do this with JPA+Spring from a unit test (you can generate the sql running the unit test from inside Eclipse like a breeze):
ExportDatabaseSchema.java:
You need an ExportDatabaseSchema-context.xml:
The applicationContext-jpa.xml contains the annotation configured entityManagerFactory bean. The trick is to inject it with & like this: "&entityManagerFactory", to dereference the spring generated proxy.