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 :)