-->
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.  [ 2 posts ] 
Author Message
 Post subject: passing parameters to hbm2ddl
PostPosted: Wed Mar 03, 2010 10:49 am 
Newbie

Joined: Tue Dec 15, 2009 1:55 am
Posts: 2
I have parametrized persistence.xml. I am trying to generate ddl schema using hbm2ddl. How can i pass parameters to this tool ?

My persistence.xml looks like

<property name="hibernate.connection.driver_class" value="${persistence.connection.driver.class}"/>
<property name="hibernate.dialect" value="${persistence.dialect}"/>
<property name="hibernate.connection.password" value="${persistence.password}"/>
<property name="hibernate.connection.username" value="${persistence.username}"/>

When i start server parameter values are passed as JAVA_OPTS (using -Dpersistence.dialect=value). And it works well.

How do i do this with hbm2ddl ?

I tried property

<hibernatetool destdir="${gensrc.sql.dir}">
<property key="persistence.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
<jpaconfiguration persistenceunit="${persistence.unit.name}" />
<classpath>
<!-- it is in this classpath you put your classes dir,
and/or jpa persistence compliant jar -->
<path location="${build.classes.dir}" />
</classpath>
<hbm2ddl export="false" drop="true" outputfilename="create_${ant.project.name}.sql" format="true" haltonerror="true" />
</hibernatetool>

But it does not get this value. It shows me error.

build.xml:160: org.hibernate.HibernateException: Dialect class not found: ${persistence.dialect}


Top
 Profile  
 
 Post subject: Re: passing parameters to hbm2ddl
PostPosted: Tue Mar 09, 2010 3:51 am 
Newbie

Joined: Tue Dec 15, 2009 1:55 am
Posts: 2
I mean -D param.
I have defined persistence.xml as this.
<property name="hibernate.dialect" value="${persistence.dialect}"/>


And while starting server (JAVA_OPTS), i pass -Dpersistence.dialect=mysql...

And it works. Issue is, in hbm2ddl its not supported. However i figured out a way. I use <jpaconfiguration propertyfile=${file.with/hibernate/dialect=oracle...}>

It woks. Sort of hack though. so at the time of building i change file to generate appropriate sqls.

It would have been clean if hbm2ddl anttask supported -D params.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.