Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# NHibernate mapping
It could not compile the mapping xml documents and i dont know why
 
this is my cfg file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <!-- an ISessionFactory instance -->
  <session-factory>
    <!-- properties -->
    <property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider
    </property>
    <property name="connection.driver_class">
      NHibernate.Driver.MySqlDataDriver
    </property>
    <property name="connection.connection_string">
      Server=127.0.0.1;Database=projekt;User ID=root;Password=pass;
    </property>
    <property name="dialect">
      NHibernate.Dialect.MySQL5Dialect
    </property>
    <!-- mapping files -->
    <mapping resource="DBprojekt.mappings.Predajna.hbm.xml" assembly="DBprojekt" />
    <mapping resource="DBprojekt.mappings.Switch.hbm.xml" assembly="DBprojekt" />
    <mapping resource="DBprojekt.mappings.Server.hbm.xml" assembly="DBprojekt" />
    <mapping resource="DBprojekt.mappings.Typkamery.hbm.xml" assembly="DBprojekt" />
    <mapping resource="DBprojekt.mappings.Kamera.hbm.xml" assembly="DBprojekt" />
    <mapping resource="DBprojekt.mappings.Port.hbm.xml" assembly="DBprojekt" />
  </session-factory>
</hibernate-configuration>
 
this is .hbm.xml file
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="DBprojekt.classtable.Switch, DBprojekt" table="switch" lazy="true" >
    <id name="Id" column="id" type="int">
      <generator class="native"></generator>
    </id>
    <property name="Ip">
      <column name="ip" sql-type="char(20)" not-null="true" />
    </property>
    <many-to-one insert="false" update="false" lazy="false" name="Predajnaid">
      <column name="predajnaid" sql-type="int(11)" not-null="false" />
    </many-to-one>
    <property name="Predajnaid">
      <column name="predajnaid" sql-type="int(11)" not-null="false" />
    </property>
    <bag name="Ports" inverse="true" cascade="none">
      <key column="" />
      <one-to-many class="Port" />
    </bag>
    <bag name="Servers" inverse="true" cascade="none">
      <key column="" />
      <one-to-many class="Server" />
    </bag>
  </class>
</hibernate-mapping>
 
and class
using System;
using System.Text;
using System.Collections.Generic;
 

namespace DBprojekt.classtable
{
 
    public class Switch
    {
        public Switch()
        {
            Ports = new List<Port>();
            Servers = new List<Server>();
        }
        public virtual int Id { get; set; }
        public virtual Predajna Predajna { get; set; }
        public virtual string Ip { get; set; }
        public virtual IList<Port> Ports { get; set; }
        public virtual IList<Server> Servers { get; set; }
    }
}
Posted 1-May-13 7:39am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 384
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 CPallini 170
4 Shweta N Mishra 165
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 1 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100