facebook

How do I auto generate/update schema with ddl using MyEclips

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #242974 Reply

    evanidul
    Member

    Hibernate 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!

    #242993 Reply

    Riyad Kalla
    Member

    Any 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.

    #243009 Reply

    evanidul
    Member

    Hey,

    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

    #243012 Reply

    Riyad Kalla
    Member

    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?

    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.

    #243053 Reply

    evanidul
    Member

    Hi,

    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!

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: How do I auto generate/update schema with ddl using MyEclips

You must be logged in to post in the forum log in