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.  [ 3 posts ] 
Author Message
 Post subject: Auto generating DDL
PostPosted: Mon Aug 14, 2006 6:06 pm 
Newbie

Joined: Mon Apr 10, 2006 11:59 am
Posts: 9
Hi,

I'm a kind of new to hibernate.

I have a couple of mapping classes on C# and the XML files.

Is there a way to generate the sql statements from the mapping file ?

If someone can provide a sample I'll aprreciate.

Thanks in advance for your help.

Best regards

Luis Filipe


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 9:03 pm 
Newbie

Joined: Mon Aug 14, 2006 8:59 pm
Posts: 2
Take a look at NHibernate.Tool.hbm2ddl.SchemaExport. Here's a (very) brief code example:

Code:
Configuration config = GetMyNHibernateConfiguration();
SchemaExport exporter = new SchemaExport(config.Configure());

exporter.Create(true, true);


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 15, 2006 8:26 am 
Newbie

Joined: Mon Apr 10, 2006 11:59 am
Posts: 9
Hi,

thanks for the tip.

I got a sample of a configuration file for nhibernate, where the name of the assembly that contains the mapping file is written.

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.0" >
   <session-factory name="NHibernate.Test">
      <!-- properties -->

      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Server=localhost\sql2005;initial catalog=bugs;User ID=sa;Password=sa_password;Min Pool Size=2</property>
      <property name="show_sql">true</property>
      <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
      
      
      <property name="use_outer_join">true</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <!-- mapping files -->
      <mapping assembly="Com.Benday.BugTracker.Business" />
   </session-factory>

</hibernate-configuration>

My question, do I need to add this configuration section with the name of the assembly that contains the mapping files ?

Thanks in advance for your help.
Best regards

Luis Filipe
Code:


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