-->
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: hbm2ddl nant task
PostPosted: Fri Mar 07, 2008 10:31 am 
Newbie

Joined: Fri Mar 07, 2008 9:30 am
Posts: 1
Hi all,

I'm trying to use the hbm2ddl nant task. I would like to auto-generate DDL script based on my mapping files.

Here is my Nant build file :

Code:
<project name="DDL Generator" default="generateDDLScript" basedir="." xmlns="http://nant.sf.net/release/0.85/nant.xsd">
  <loadtasks assembly="C:\Program Files\NHibernate\bin\net-2.0\NHibernate.Tasks.dll"/>
  <target name="generateDDLScript">
    <hbm2ddl connectionprovider="NHibernate.Connection.DriverConnectionProvider"
             dialect="NHibernate.Dialect.MsSql2005Dialect"
             connectiondriverclass="NHibernate.Driver.SqlClientDriver"
             connectionstring="data source=.\SQLEXPRESS;database=Test;Trusted_Connection=Yes;"
             droponly="false"
             exportonly="true"
             delimiter=" GO "
             outputtoconsole="false"
             formatnice="true"
             outputfilename=".\Test.sql">
      <assemblies>
        <include name=".\MyTestProject.Dal.dll"></include>
      </assemblies>
    </hbm2ddl>
  </target>
</project>


(Note : the mapping files are embedded as resources in the MyTestProject.Dal.dll assembly)

When I launch the build, here are the console traces :

Code:
NAnt 0.85 (Build 0.85.2478.0; release; 14/10/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/Temp/DDL.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: generateDDLScript

[loadtasks] Scanning assembly "NHibernate.Tasks" for extensions.

generateDDLScript:

  [hbm2ddl] Adding assembly file C:\Temp\MyTestProject.Dal.dll
  [hbm2ddl] Successful DDL schema output: .\Test.sql

BUILD SUCCEEDED

Total time: 0.3 seconds.


The result is an empty Test.sql file...
Any idea what's wrong here ?

Thanks by advance,

Nicolas


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 10, 2008 2:41 pm 
Newbie

Joined: Sat May 10, 2008 2:37 pm
Posts: 2
Was there ever an answer found for this? I'm having the exact same issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 13, 2008 9:26 pm 
Newbie

Joined: Sat May 10, 2008 2:37 pm
Posts: 2
I may have figured this out. My configuration assumed that my mapping files were embedded but I failed to include them as resources in my Nant build process.

I say "may have" because when I couldn't get the task to work I created a console application to generate the DDL and I was having the same issue... an empty *.sql file. After I embedded the mapping files properly everything worked fine. I haven't gone back to set this up as a task to see if it works but I assume it will.

So bottom line... make sure your mapping files are embedded resources if you a expecting them to be.


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.