-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Generating DDL for multiple databases
PostPosted: Sat Sep 12, 2009 7:41 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:28 pm
Posts: 26
I'm having some trouble with the ant task. I publish a JPA-using opensource project and want to generate DDL files for several different database dialects to include in the distribution, including DDL for databases I don't have running anywhere.

My first attempt looks like this:

Code:
      <hibernatetool destdir="${build.dir}/ddl">
         <classpath ...blah blah
         
         <property key="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
         <jpaconfiguration persistenceunit="subetha" />
         
         <hbm2ddl format="true" outputfilename="mysql5.sql" />
      </hibernatetool>


However, the task complains that I must specify a dialect. It appears that you cannot specify a dialect with a <property>. I did, however, find an undocumented "propertyfile" attribute on <jpaconfiguration>, so I've tried this:

Code:
      <hibernatetool destdir="${build.dir}/ddl">
         <classpath ...blah blah
         
         <jpaconfiguration persistenceunit="subetha" propertyfile="mysql5.properties"/>
         
         <hbm2ddl format="true" outputfilename="mysql5.sql" />
      </hibernatetool>


Where mysql.properties contains "hibernate.dialect=org.hibernate.dialect.MySQL5Dialect". Now this produces an error "unable to find datasource". That makes some amount of sense, hbm2ddl normally updates the DB. So I try setting <hbm2ddl export="false":

Code:
      <hibernatetool destdir="${build.dir}/ddl">
         <classpath ...blah blah
         
         <jpaconfiguration persistenceunit="subetha" propertyfile="mysql5.properties"/>
         
         <hbm2ddl export="false" format="true" outputfilename="mysql5.sql" />
      </hibernatetool>


This runs successfully but mysql5.sql is an empty (0-byte) file.

What am I missing?

I'm using the current released versions of everything.

Thanks in advance,
Jeff


Top
 Profile  
 
 Post subject: Re: Generating DDL for multiple databases
PostPosted: Mon Sep 14, 2009 2:29 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:28 pm
Posts: 26
vyemialyanchyk wrote:
I could suggest you use "Hibernate Tools" (eclipse plugins bundle - part of JBoss Tools, possible to use separately) for this.
More info: http://docs.jboss.org/tools/2.1.0.Beta1/hibernatetools/html, https://www.hibernate.org/6.html.
1) setup Hibernate Tools (Link to download Hibernate Tools: http://downloads.sourceforge.net/jboss/HibernateTools-3.2.4.GA-R200905070146-H18.zip);
2) open Hibernate perspective;
3) create Hibernate Console Configuration for your project - on Main tab (Type: JPA), on Option tab - specify db dialect;
4) find Hibernate Code Generation Configurations -> specify you Hibernate Console Configuration and output directory (could be direct path like "c:/tmp"), on Exporters Tab - select "Schema Export" -> properties -> add -> set your output file name;
this should work.


Thanks, I appreciate the response. However, this needs to be run from the command line (ie Ant) as part of the distro build process. I'm using the ant task that came with Hibernate Tools (hibernate-tools.jar, found hidden away in one of the eclipse plugin directories).

Jeff


Top
 Profile  
 
 Post subject: Re: Generating DDL for multiple databases
PostPosted: Wed Sep 16, 2009 5:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
which version are you using of Hibernate and Hibernate tools ?

There were issues about export not actually writing to the file in some older versions of Hibernate (its the core that actually does schemaexport, not the tools). Try use the latest version of Hibernate 3.2.x or 3.3.x - if that doesnt help open a bug.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Generating DDL for multiple databases
PostPosted: Wed Sep 16, 2009 6:33 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 6:28 pm
Posts: 26
max wrote:
which version are you using of Hibernate and Hibernate tools ?

There were issues about export not actually writing to the file in some older versions of Hibernate (its the core that actually does schemaexport, not the tools). Try use the latest version of Hibernate 3.2.x or 3.3.x - if that doesnt help open a bug.


I'm using the latest, 3.3.2.GA. I'll open a bug.

Thanks,
Jeff


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.