- This topic has 4 replies, 2 voices, and was last updated 19 years, 5 months ago by
evanidul.
-
AuthorPosts
-
evanidulMemberHibernate comes with a Schema creation tool and Schema update tool. The creation tool is called hbm2ddl. I was wondering how I might use this tool to generate ddl for a MySql database? I’d like to be able to write POJO’s in myeclipse, write the hbm.xml mapping files, and then use hbm2ddl to generate a ddl script for MySql. I’d also like to be able to use similar hib tools to just update my schema.
There are ant solutions for doing this with hibernate. Though, I’m not sure how to integrate that with MyEclipse, since MyEclipse is doing a bunch of other deployment tasks when it’s deploying my j2ee war file to Tomcat. Thanks for any help!
Riyad KallaMemberAny integration of these Hibernate tasks would need to be done manually, probably via an Ant script that you write, we don’ts upport them directly so there isn’t support necessarily from the UI.
evanidulMemberHey,
When I click “deploy” from the toolbar to build my war and deploy it to tomcat, that’s just myeclipse running an ant script in the background right? I’m just asking because if you could provide me the location of that ant script, I may be able to use it as a template and tweak whatever hibernate settings I need. That would be of great help!
Thanks,
Dan
Riyad KallaMemberWhen I click “deploy” from the toolbar to build my war and deploy it to tomcat, that’s just myeclipse running an ant script in the background right?
No, actually far from it even though it seems very “anty” in nature. You’ll start to get why when you make use of project dependencies, deployment rules and smart deployment in packaged/exploded deployments. I’m not implying it would be impossible to implement in Ant, but there hasn’t been huge user demand for it to be Ant to justify how much it would cost us to implement in developer time.
evanidulMemberHi,
I was able to automatically create the database schema by plugging in :
<property name=”hbm2ddl.auto”>update</property>
in to hibernate.cfg.xml. You can also use “create” instead of “update” if you want the schema to be dropped and recreated everytime hibernate fires up. “update” leaves the previous schema intact and only modifies the schema to reflect current changes (new mapping files, etc).
If anyone knows how to use this property to dump the ddl to a file, that would be great 🙂 I’m sure I can find some mysql tool to do this, but doing it from hibernate would be a little more elegant.
Thanks!
-
AuthorPosts