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: Could not compile the mapping document
PostPosted: Tue Jan 29, 2008 6:42 am 
Beginner
Beginner

Joined: Mon Jan 21, 2008 8:57 am
Posts: 20
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HibernateTest.TestSpec,HibernateTest , Version=1.0.0.0, Culture=neutral" table="TestSpec">

<id name="TestSpecId" column="TestSpecId" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property column="Author" type="String" name="Author" not-null="true" length="50" />
<property column="CreationDate" type="DateTime" name="CreationDate" not-null="true" />
<property column="Description" type="byte[]" name="Description" />
<property column="DataTypeId" type="Int32" name="DataTypeId" />
<property column="ProgramId" type="Int32" name="ProgramId" not-null="true" />

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Configuration cfg = new Configuration();
cfg.AddAssembly("HibernateTest");

ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();


FileStream fs = new FileStream(@"C:\maintest2.doc", FileMode.Open);
byte[] dataArray = new byte[fs.Length];
ReadData(fs, dataArray);

TestSpec testSpec = new TestSpec();
testSpec.CreationDate = DateTime.Now;
testSpec.Author = "MyName";
testSpec.Description = dataArray;




// Tell NHibernate that this object should be saved
session.Save(testSpec);

// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();


Full stack trace of any exception that occurs:
> HibernateTest.exe!HibernateTest.Form1.Form1_Load(object sender = {HibernateTest.Form1, Text: Form1}, System.EventArgs e = {System.EventArgs}) Line 44 C#
[External Code]
HibernateTest.exe!HibernateTest.Program.Main() Line 17 + 0x1a bytes C#
[External Code]

Name and version of the database you are using:
MSQL2000


Hi, I have been working with this for a while:
When I try to run my little test program, I get that the "Could not compile the mapping document: HibernateTest.TestSpec.hbm.xml" error. I have remembered to make the file embedded, but I can't see what else i could do better. I have used MyGeneration to generate the mapping.
Help is greatly appreciated :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 29, 2008 10:33 am 
Newbie

Joined: Fri Dec 14, 2007 3:20 pm
Posts: 8
Not sure, obviously my first thought was the embedded issue, it's caught me a few times.

What I'd recommend is using some try/catch blocks around session creation etc. You can catch an NHibernate.HibernateException.

In the InnerException there is usually good detail like "Invalid Column Name" etc that will help troubleshoot.

If still no luck, post the exception details here


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 3:38 am 
Beginner
Beginner

Joined: Mon Jan 21, 2008 8:57 am
Posts: 20
I found the error myself. I have used myGeneration to generate the mappings, and apparently it converts my Binary fields to byte[], which NHibernate doesn't understand.


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.