-->
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.  [ 3 posts ] 
Author Message
 Post subject: Bad mapping generation. It don't generate generator node.
PostPosted: Sun Jan 15, 2006 5:17 am 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
NHibernate version:
1.0.1.0
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2006-01-15 09:52:27Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BibLog.Hbm.Kategoria, BibLog-lib">
    <id column="id">
      <generator class="native" />
    </id>
    <property name="nazwa" not-null="true" />
  </class>
  <class name="BibLog.Hbm.Wydanie, BibLog-lib">
    <id column="id" />
    <property name="tytul" not-null="true" />
    <property name="isbn" unique="true" />
    <property name="rokWydania" column="rok_wydania" not-null="false" />
    <many-to-one name="kategoria" not-null="true" />
    <set name="autorzy" table="WydanieAutor">
      <key column="wydanie_id" />
      <many-to-many class="BibLog.Hbm.Autor, BibLog-lib" column="autor_id" />
    </set>
  </class>
  <class name="BibLog.Hbm.Autor, BibLog-lib">
    <id column="id" />
    <property name="imie" />
    <property name="nazwisko" />
    <property name="pseudonim" />
  </class>
  <class name="BibLog.Hbm.Ksiazka, BibLog-lib">
    <id column="id" />
    <property name="iboId" column="ibo_id" not-null="true" />
    <many-to-one name="kategoria" not-null="true" />
  </class>
</hibernate-mapping>

Full stack trace of any exception that occurs:
Bad schema validation (empty id element).
Code:
NHibernate.MappingException: The element 'id' in namespace 'urn:nhibernate-mapping-2.0' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:column urn:nhibernate-mapping-2.0:generator'. ---> System.Xml.Schema.XmlSchemaValidationException: The element 'id' in namespace 'urn:nhibernate-mapping-2.0' has incomplete content. List of possible elements expected: 'urn:nhibernate-mapping-2.0:meta urn:nhibernate-mapping-2.0:column urn:nhibernate-mapping-2.0:generator'.
   at NHibernate.Cfg.Configuration.ValidationHandler(Object o, ValidationEventArgs args)
   at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent(ValidationEventHandler eventHandler, Object sender, XmlSchemaValidationException e, XmlSeverityType severity)
   at System.Xml.Schema.XmlSchemaValidator.CompleteValidationError(ValidationState context, ValidationEventHandler eventHandler, Object sender, String sourceUri, Int32 lineNo, Int32 linePos, Boolean getParticles)
   at System.Xml.Schema.XsdValidator.ValidateEndElement()
   at System.Xml.Schema.XsdValidator.Validate()
   at System.Xml.XmlValidatingReaderImpl.ProcessCoreReaderEvent()
   at System.Xml.XmlValidatingReaderImpl.Read()
   at System.Xml.XmlValidatingReader.Read()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at NHibernate.Cfg.Configuration.LoadMappingDocument(XmlTextReader hbmReader)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
   --- End of inner exception stack trace ---
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
   at BibLog.DAO.DAO`1.Init(String connString) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog-lib\DAO.cs:line 34
   at BibLog.DAO.DAO`1.Init(String host, String user, String pass, String db) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog-lib\DAO.cs:line 20
   at BibLog.GUI.LogIn.OnResponse(ResponseType type) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog\BibLogGui\LogIn.cs:line 32
   at Gtk.Dialog.response_cb(IntPtr dialog, Int32 response_id)
   at Gtk.Dialog.gtk_dialog_run(IntPtr raw)
   at Gtk.Dialog.Run()
   at BibLog.GUI.BibLog.Main(String[] args) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog\BibLogGui\BibLog.cs:line 12}   

Code:
Code:
using System;
using System.Collections;
using NHibernate.Mapping.Attributes;

namespace BibLog.Hbm {
   [Class]
   public class Autor {
      [Id(Column="id")]
      [Generator(Class="native")]
      public ulong id;
      
      [Property]
      public String imie;
      [Property]
      public String nazwisko;
      [Property]
      public String pseudonim;
   }
   [Class]
   public class Kategoria {
      [Id(Column="id")]
      [Generator(Class="native")]
      public ulong id;
      
      [Property(NotNull=true)]
      public String nazwa;
   }
   [Class]
   public class Ksiazka
   {
      [Id(Column="id")]
      [Generator(Class="native")]
      public ulong id;
      
      [ManyToOne(NotNull=true)]
      public Wydanie kategoria;
      
      [Property(NotNull=true,Column="ibo_id")]
      public ulong iboId;
   }
   [Class]
   public class Wydanie {
      [Id(Column="id")]
      [Generator(Class="native")]
      public ulong id;
      
      [Property(NotNull=true)]
      public String tytul;
      [Property(Unique=true)]
      public String isbn;
      [Property(NotNull=false, Column="rok_wydania")]
      public DateTime rokWydania;
      [ManyToOne(NotNull=true)]
      public Kategoria kategoria;
      
      [Set(Table="WydanieAutor")]
      [Key(Column="wydanie_id")]
      [ManyToMany(Column="autor_id", ClassType=typeof(Autor))]
      public ICollection autorzy;
   }
}


What's wrong?
I don't understand it...
(And with access attrubute is all ok?)

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 15, 2006 8:48 am 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Ok.
Now the code is:
Code:
using System;
using NHibernate.Mapping.Attributes;

namespace BibLog.Hbm {
   [Class]
   public class Autor {
      [Id(0, Column="id")]
      [Generator(1, Class="native")]
      public ulong id;
      
      [Property]
      public String imie;
      [Property]
      public String nazwisko;
      [Property]
      public String pseudonim;
   }
   [Class]
   public class Kategoria {
      [Id(0, Column="id")]
      [Generator(1, Class="native")]
      public ulong id;
      
      [Property(NotNull=true)]
      public String nazwa;
   }
   [Class]
   public class Ksiazka {
      [Id(0, Column="id")]
      [Generator(1, Class="native")]
      public ulong id;
      
      [ManyToOne(NotNull=true)]
      public Wydanie wydanie;
      
      [Property(NotNull=true,Column="ibo_id")]
      public ulong iboId;
   }
   [Class]
   public class Wydanie {
      [Id(0, Column="id")]
      [Generator(1, Class="native")]
      public ulong id;
      
      [Property(NotNull=true)]
      public String tytul;
      [Property(Unique=true)]
      public String isbn;
      [Property(NotNull=false, Column="rok_wydania")]
      public DateTime rokWydania;
      [ManyToOne(NotNull=true, ClassType=typeof(Kategoria))]
      public Kategoria kategoria;
      
      [Set(Table="WydanieAutor")]
      [Key(Column="wydanie_id")]
      [ManyToMany(Column="autor_id", ClassType=typeof(Autor))]
      public ICollection autorzy;
   }
}

And generated xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2006-01-15 13:32:57Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BibLog.Hbm.Kategoria, BibLog-lib">
    <id column="id">
      <generator class="native" />
    </id>
    <property name="nazwa" not-null="true" />
  </class>
  <class name="BibLog.Hbm.Wydanie, BibLog-lib">
    <id column="id">
      <generator class="native" />
    </id>
    <property name="tytul" not-null="true" />
    <property name="isbn" unique="true" />
    <property name="rokWydania" column="rok_wydania" not-null="false" />
    <many-to-one name="kategoria" class="BibLog.Hbm.Kategoria, BibLog-lib" not-null="true" />
    <set name="autorzy" table="WydanieAutor">
      <key column="wydanie_id" />
      <many-to-many class="BibLog.Hbm.Autor, BibLog-lib" column="autor_id" />
    </set>
  </class>
  <class name="BibLog.Hbm.Autor, BibLog-lib">
    <id column="id">
      <generator class="native" />
    </id>
    <property name="imie" />
    <property name="nazwisko" />
    <property name="pseudonim" />
  </class>
  <class name="BibLog.Hbm.Ksiazka, BibLog-lib">
    <id column="id">
      <generator class="native" />
    </id>
    <property name="iboId" column="ibo_id" not-null="true" />
    <many-to-one name="wydanie" not-null="true" />
  </class>
</hibernate-mapping>

but...
It throws:
Code:
NHibernate.MappingException: must specify an identifier type: Kategoria
   at NHibernate.Cfg.Binder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindRoot(XmlDocument doc, Mappings model)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc)
   at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
   at BibLog.DAO.DAO`1.Init(String connString) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog-lib\DAO.cs:line 41
   at BibLog.DAO.DAO`1.Init(String host, String user, String pass, String db) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog-lib\DAO.cs:line 20
   at BibLog.GUI.LogIn.OnResponse(ResponseType type) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog\BibLogGui\LogIn.cs:line 32
   at Gtk.Dialog.response_cb(IntPtr dialog, Int32 response_id)
   at Gtk.Dialog.gtk_dialog_run(IntPtr raw)
   at Gtk.Dialog.Run()
   at BibLog.GUI.BibLog.Main(String[] args) in c:\Documents and Settings\Maciej Piechotka\Moje dokumenty\SharpDevelop Projects\BibLog\BibLogGui\BibLog.cs:line 12


What's wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 16, 2006 11:45 am 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
It's ok now.
NHibernate didn't recognized ulong type and I had to add Type="UInt64".

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.