Starting with NHibernate

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-04-20T19:00:05Z Indexed on 2010/04/20 19:03 UTC
Read the original article Hit count: 313

Filed under:
|
|

I'm having major difficulties to start off with NHiberante.

Main problems:

Where my hbm.xml files should reside? I create a Mappings folder but I received an error "Could not find xxx.hbm.xml file."

I tried to load the specific class through the dialect cf.AddClass(typeof(xxx)); but it still gives me the same error (the files are marked as embebed resources.

Also I'm having major problems in connection to it. I stopped trying to use the cfg xml file and tried a more direct approach with a library I have here.

Configuration cfg = new Configuration();
        cfg.AddClass(typeof(Tag));

        ISessionFactory sessions = cfg.BuildSessionFactory();
        AgnosticConnectionHandler agch = new AgnosticConnectionHandler("xxx","xxx","geo_biblio","localhost",
            5432,DatabaseInstance.PostgreSQL);
        ISession sessao = sessions.OpenSession(agch.GetConnection);

        ITransaction tx = sessao.BeginTransaction();

        Tag tag1 = new Tag();
        tag1.NomeTag = "Teste Tag NHibernate!!!";

        sessao.Save(tag1);
        tx.Commit();
        sessao.Close();

Any tips for me? I'm getting the exception in line 2 of this code, and still not sure what to do.

Any help is appreciated. Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about nhibernate