-->
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: Hbm2ddl
PostPosted: Sun Jul 01, 2007 7:32 am 
Newbie

Joined: Sun Jul 01, 2007 4:10 am
Posts: 5
Hi does anyone have an example that use hbm2ddl to create the database?

I need som help with it, i have my classes ant hbm.xml files. with this i want to create the database, so that i know that the database gets the right structure.

I appreciate all the help i can get with this, i have searched alot but cant figure it out!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 01, 2007 6:59 pm 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
There is an HibernateTask for cleaning/creating the database if you are using NAnt.
Otherwise, check around for docs on SchemaExport, the tool to use to do this.
Basically, you need a reference to you ISession and your NHibernate configuration object. Then you can:
Code:
IDbConnection connection = session.Connection;
new SchemaExport(configuration).Execute(false, true, false, true, connection, null);


Hope this helps

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 10:35 am 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
One other note... the SchemaExport object currently only supports execution always with a conditional drop. So, don't execute at startup if there will be an existing database--it will get blown away.

In general, SchemaExport is very unsophisticated... but very useful for unit testing where you'd always like to have a brand-new DB at each test run, especially if you are changing your schema as you go. However, it is currently useless as a schema versioning tool in a production scenario.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 1:32 pm 
Newbie

Joined: Sun Jul 01, 2007 4:10 am
Posts: 5
mnichols wrote:
There is an HibernateTask for cleaning/creating the database if you are using NAnt.
Otherwise, check around for docs on SchemaExport, the tool to use to do this.
Basically, you need a reference to you ISession and your NHibernate configuration object. Then you can:
Code:
IDbConnection connection = session.Connection;
new SchemaExport(configuration).Execute(false, true, false, true, connection, null);


Hope this helps


i´m not using NAnt, just started with Nhibernate, so i should search on SchemaExport?

Is it hard to configure Nhibernate to use schema export with my mapping files?


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.