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: Nhibernate mappingexception with postgreSQL
PostPosted: Thu Feb 07, 2008 6:09 am 
Newbie

Joined: Thu Feb 07, 2008 6:01 am
Posts: 1
I made a simple database with a few columns

Code:
CREATE TABLE surveys
(
  "name" character varying(40) NOT NULL DEFAULT NULL::character varying,
  groupname character varying(40) DEFAULT NULL::character varying,
  status integer DEFAULT 0,
  priority integer DEFAULT 10,
  CONSTRAINT pk_name PRIMARY KEY (name)
)


my mapping files look like this

App.config:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section
      name="nhibernate"
      type="System.Configuration.NameValueSectionHandler, System,
         Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  </configSections>

  <nhibernate>
    <add
      key="hibernate.connection.provider"
      value="NHibernate.Connection.DriverConnectionProvider"
    />
    <add
      key="hibernate.dialect"
      value="NHibernate.Dialect.PostgreSQLDialect"
    />
    <add
      key="hibernate.connection.driver_class"
      value="NHibernate.Driver.NpgsqlDriver"
    />
    <add
      key="hibernate.connection.connection_string"
      value="Server=localhost;Database=nhibernate;User Name=postgres;Password=****"
    />
  </nhibernate>
 
</configuration>


and my mapping file for my class:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="nhibernateTest.Survey, nhibernateTest" table="surveys">
    <id name="Name" column="name" type="string" length="40">
      <generator class="assigned" />
    </id>
    <property name="GroupName" column="groupname" type="string" length="40"/>
    <property name="Status" column="status"  type="integer" />
    <property name="Priority" column="priority"  type="integer"/>
  </class>
</hibernate-mapping>


And to save data i use:
Code:
                cfg.AddAssembly("nhibernateTest");

                ISessionFactory factory = cfg.BuildSessionFactory();

                ISession session = factory.OpenSession();

                ITransaction transaction = session.BeginTransaction();

                session.Save(session);

                transaction.Commit();

                session.Close();


but i keep getting this error:
Code:
NHibernate.MappingException was unhandled
  Message="Could not compile the mapping document: nhibernateTest.Survey.hbm.xml"
  Source="NHibernate"
  StackTrace:
       at NHibernate.Cfg.Configuration.LogAndThrow(MappingException me)
       at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
       at NHibernate.Cfg.Configuration.ProcessMappingsQueue()
       at NHibernate.Cfg.Configuration.AddDocumentThroughQueue(NamedXmlDocument document)
       at NHibernate.Cfg.Configuration.AddXmlReader(XmlTextReader hbmReader, String name)
       at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
       at NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly)
       at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
       at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
       at nhibernateTest.Program.Main(String[] args) in C:\Documents and Settings\Glenn\My Documents\Visual Studio 2005\Projects\nhibernateTest\nhibernateTest\Program.cs:line 32
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


i've been looking for a while now, but can't seem to solve this. Any suggestions? :-)


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.