-->
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: Automatic database creation
PostPosted: Fri Apr 04, 2008 4:38 am 
Newbie

Joined: Tue Feb 27, 2007 3:58 am
Posts: 5
Location: Netherlands
Hibernate version: 3.2.5

Name and version of the database you are using: Oracle, MySQL, MS SQL


Hello, we have a software-application that works perfectly, for different customers, with different databases.

But I don't want to switch databases everytime I have to develop for a different customer.

So I would like Hibernate to create the schema's for me, so I don't have to convert all the databases.

I used this setting: hibernate.hbm2ddl.auto=create
But nothing gets created, it just gives errors that tabels don't exist.

Am i misunderstanding what this property should / can do, or have I not configured something right?

The setting get's loaded properly;
Code:
2008-04-04 09:28:14,359 INFO  Environment              : loaded properties from resource hibernate.properties: {hibernate.servicename=imos/TRB:service=HibernateFactory, hibernate.cache.use_second_level_cache=true, hibernate.show_sql=false, hibernate.jdbc.batch_size=500, hibernate.bytecode.use_reflection_optimizer=false, hibernate.jdbc.fetch_size=16, hibernate.default_batch_fetch_size=500, hibernate.jndiname=java:/imos/TRB/HibernateFactory, hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup, hibernate.hbm2ddl.auto=create, hibernate.jdbc.wrap_result_sets=true, hibernate.cache.use_query_cache=true, hibernate.datasource=java:/TRB-DS, hibernate.dependency.b=jboss.jca:service=LocalTxCM,name=TRB-DS, hibernate.dependency.a=jboss.jca:service=RARDeployer, hibernate.cache.provider_class=org.hibernate.cache.TreeCacheProvider, hibernate.transaction.name=UserTransaction, hibernate.cache.use_structured_entries=true, hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory, hibernate.dialect=org.hibernate.dialect.Oracle9iDialect}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 04, 2008 5:26 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
I don't know what this configuration does. But I know u can invoke hbm2ddl using an ant script.

Here is a sample ant script

Code:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"/>

<hibernatetool destdir=".">
<configuration propertyfile="hibernate.properties">
<fileset dir="C:/HBM" id="id">
<include name="application.hbm.xml"/>
</fileset>
</configuration>
<hbm2ddl outputfilename="application.ddl" export="false" create="true" />
</hibernatetool>




If you make export="true" the tables will be automatically created in the schema you have mentioned in your hibernate.properties file.

For further information on hbm2ddl, you should post your questions in hibernate tools forum. Thats where all the discussions on schema generations take place

_________________
Sukirtha


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.