3 Replies Latest reply on Apr 16, 2010 4:42 PM by Julia Smith

    Database schema generation with Annotations

    Hussein Baghdadi Novice

      Usually, I use Hibernate hbm files to generate my database schema.
      Is it possible to generate database schema if I use Hibernate annotations instead of hbm files?

        • 2. Re: Database schema generation with Annotations
          Ivan Bojer Newbie

          I am sorry I've clicked button too soon. Here is a sample from one of our targets that does exactly that:

          <target name="schemaexport" depends="compile" description="Exports a generated schema to DB and file">
           <hibernatetool destdir="${source.root}">
           <annotationconfiguration configurationfile="${class.root}/hibernate.cfg.xml"/>
           <hbm2ddl drop="true" create="true" />

          • 3. Re: Database schema generation with Annotations
            Julia Smith Newbie

            I've done the rounds on google, but dead-ended in jar versioning or other issues, such as the relevant hibernate docs pages 404ing. What seemed like a nifty idea using pojos -> schema generation has turned into a 16 hour waste of time.


            I have to ask if there is a simple project somebody can post listing jar files and where to get the _correct_ versions that work together, the necessary xml files (ant, hibernate, perisistence whatever) just something that can produce a .sql file for a simple java class.


            I tried this thinking it would be easier than generating db tables and reverse engineering it, but unfortunately this isn't the case. I have to say this exercise hasn't save me any grief or typing. I could have developed the tables and written by hand the java classes in this amount of time.


            Sorry to send a nasty-gram, but that has been my experience.