Desperately need some help

1 view
Skip to first unread message

raihan

unread,
Nov 20, 2009, 10:44:56 AM11/20/09
to nhusers
I have been struggling a great deal with NHIbernate – I am trying to
use it for the first time in a project and getting nowhere with it.
I would really appreciate anyone's help in figuring out what I am
doing wrong.
Here is what I have for the project –
Assembly name – LicenseServer
Root Namespace – CXI.LicenseServer
All my model objects are under CXI.LicenseServer.Model namespace along
with their mapping files. Mapping files are compiled as embedded
resources.

Here is hibernate configuration in app.config –

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">
NHibernate.Driver.NpgsqlDriver
</property>
<property name="connection.connection_string">
Server=localhost;database=db_test;User
ID=test_user;Password=test123;
</property>
<property name="dialect">
NHibernate.Dialect.PostgreSQLDialect
</property>
<property name="show_sql">
false
</property>
<property
name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory,
NHibernate.ByteCode.LinFu</property>
<mapping assembly="LicenseServer" />
</session-factory>
</hibernate-configuration>

Here is part of my Agency object –

using System;

namespace CXI.LicenseServer.Model
{
/// <summary>
/// Description of Agency.
/// </summary>
public class Agency
{
private string agencyID;
public virtual string AgencyID {
get { return agencyID; }
set
{
if(String.IsNullOrEmpty(value)
|| value.Trim().Length != 9)
{
throw new ArgumentException("Agency ID
must be 9 characters long!");
}
agencyID = value;
}
}

private string agencyName;
public virtual string AgencyName {
get { return agencyName; }
set { agencyName = value; }
}
}
}

Here is my Agency.hbm.xml mapping file –

<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="CXI.LicenseServer.Model" assembly="LicenseServer">
<class name="CXI.LicenseServer.Model.Agency,
CXI.LicenseServer.Model" table="agency">
<id name=" AgencyID" column="agencyid"/>
<generator class="assigned" />
</id>

<property name="AgencyName">
<column name="agencyname"/>
</property>
</class>
</hibernate-mapping>

If I keep the generator element, then I get an error saying generator
element is invalid child of class element under 2.2 schema.
If I comment that out, then I get the “Could not configure datastore
from input stream CXI.LicenseServer.Model.Agency.hbm.xml” error.

I have looked and looked without any luck! I am just frustrated to
the point of giving up! But so many people are using NHibernate out
there without any issues!

Please help!
Raihan

Oskar Berggren

unread,
Nov 20, 2009, 6:21:40 PM11/20/09
to nhu...@googlegroups.com
<id name=" AgencyID" column="agencyid"/>

You have an extra slash there...

/Oskar


2009/11/20 raihan <ruabn...@gmail.com>:
> --
>
> You received this message because you are subscribed to the Google Groups "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nhusers?hl=.
>
>
>

raihan

unread,
Nov 22, 2009, 10:30:01 AM11/22/09
to nhusers
I feel like a stupid! Yes, that extra slash was causing those
issues. Thanks so much Oskar!
I took that out, but now I have the error that says "could not compile
the mapping document CXI.LicenseServer.Model.agency.hbm.xml" or
something like that. I must mention that the agency class has other
properties that I did not include in the mapping file. I was just
trying out with one property to see if I can get going with
NHibernate. Do you think that is causing an issue? But I remember
reading that if I don't mention other properties, NHIbernate will
simply not persist them.
Please help! Again
Raihan

On Nov 20, 6:21 pm, Oskar Berggren <oskar.bergg...@gmail.com> wrote:
>    <id name=" AgencyID" column="agencyid"/>
>
> You have an extra slash there...
>
> /Oskar
>
> 2009/11/20 raihan <ruabng2...@gmail.com>:

Oskar Berggren

unread,
Nov 22, 2009, 11:35:06 AM11/22/09
to nhu...@googlegroups.com
Do you get an inner exception with more details?

/Oskar

2009/11/22 raihan <ruabn...@gmail.com>:

raihan

unread,
Nov 23, 2009, 10:01:49 AM11/23/09
to nhusers
Hi Oskar,
I have figured out what was wrong - <class
name="CXI.LicenseServer.Model.Agency,CXI.LicenseServer.Model"> - here
I specified the CXI.LicenseSeerver.Model as the assembly, but it is
simply a namespace in my assembly. So, NHIbernate failed while trying
to load it. I deleted it from the class element, and it worked.
Thanks so much for all the help! I have overcame the initial hurdle
of using NHIbernate with your help:) I am sure I will run into more
issues, which I will have to seek yours and others' help in this
forum.
Have a great day Oskar:)
Raihan

On Nov 22, 11:35 am, Oskar Berggren <oskar.bergg...@gmail.com> wrote:
> Do you get an inner exception with more details?
>
> /Oskar
>
> 2009/11/22 raihan <ruabng2...@gmail.com>:> I feel like a stupid!  Yes, that extra slash was causing those
Reply all
Reply to author
Forward
0 new messages