-->
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.  [ 1 post ] 
Author Message
 Post subject: How to use schemaexport in another application
PostPosted: Wed May 02, 2007 9:24 am 
Newbie

Joined: Wed May 02, 2007 5:37 am
Posts: 1
Hibernate version: NHibernate-1.2.0.CR2
Name and version of the database you are using:MsSql2005

Hi all,
I have a program that creates hbm.xml-files and the cfg.xml-file from a given assembly: It reads the assembly, and creates mappingfiles for the classes in the assembly.
That all works. Now I want to update the database with schemaexport. This is where it goes wrong. The assembly cannot be found.
Here is my code:
Code:
Configuration cfg = new Configuration();

//add the configfile as a stream
cfg.Configure(new XmlTextReader(GenerateConfiguration(false)));

//For testing I add only one file
string directoryMappings = "..\..\..\ConsoleApplication1\NHibernate";
string pathMappingFile = Path.Combine(directoryMappings, "Person.hbm.xml");
cfg.AddFile(pathMappingFile);

SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.Create(true, false);


The configuration works, but an error is generated when I try to add the file.
The file is found, the error is as shown below:
Code:
Could not compile the mapping document: ..\..\..\ConsoleApplication1\NHibernate\Person.hbm.xml

with the Exception
   at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)
   at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name)
   at NHibernate.Cfg.Configuration.AddXmlFile(String xmlFile)
   at NHibernate.Cfg.Configuration.AddFile(String xmlFile)
   at TestClass.OutputGenerator.GenerateDatabase()

The Exception has the following InnerExceptions:
-persistent class Debugging.Pimspace.Person, ConsoleApplication1 not found
-Could not load file or assembly 'ConsoleApplication1' or one of its dependencies. The system cannot locate the given path.

I think because that I use an external assembly, the system cannot locate the assembly, and throws the exception. Is there any way I can add the assembly to the configuration, so it will know that it must look in that assembly?

Thanks in advance,
Pim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.