-->
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.  [ 7 posts ] 
Author Message
 Post subject: Tree!? what's wrong?
PostPosted: Sun Dec 18, 2005 10:56 am 
Newbie

Joined: Sun Dec 18, 2005 10:22 am
Posts: 5
i am a beginner , NHibernate is good,but i have some trouble with the Tree.
thanks


Code:
using System;
using System.Collections;

namespace NHibernateStudy.DAL
{

   public class Tag
   {
      private int _TagID;
      private string _TagName;
      private Tag _ParentTag;
      private IDictionary _ChildTag;


      public Tag()
      {

      }

      public int TagID
      {
         get
         {
            return _TagID;
         }
         set
         {
            _TagID = value;
         }
      }

      public string TagName
      {
         get
         {
            return _TagName;
         }
         set
         {
            _TagName = value;
         }
      }


      public Tag ParentTag
      {
         get
         {
            return _ParentTag;
         }
         set
         {
            _ParentTag = value;
         }
      }

      public IDictionary ChildTag
      {
         get
         {
            return _ChildTag;
         }
         set
         {
            _ChildTag = value;
         }
      }

   }
}



bhm here
Code:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="NHibernateStudy.DAL" assembly="NHibernateStudy">

<class name="NHibernateStudy.DAL.Tag . NHibernateStudy" table="Tag" >
   <id name="TagID" column="TagID" type="Int32" unsaved-value="0">
      <generator class="native" />
   </id>
   
   <property name="TagName" column="TagName" />

   <many-to-one name="ParentTag" class="NHibernateStudy.DAL.Tag , NHibernateStudy" column="ParentTagID" />
   <set name="ChildTag" inverse="true">
      <key column="ParentTagID" />
      <one-to-many class="NHibernateStudy.DAL.Tag , NHibernateStudy" />
   </set>
</class>


</hibernate-mapping>





always have wrong
Code:
2005-12-18 22:52:23,406 [2552] INFO  NHibernate.Cfg.Environment [(null)] & ;(null)& ; - NHibernate 1.0.1.0
2005-12-18 22:52:23,437 [2552] INFO  NHibernate.Cfg.Environment [(null)] & ;(null)& ; - Using reflection optimizer
2005-12-18 22:52:23,437 [2552] INFO  NHibernate.Cfg.Configuration [(null)] & ;(null)& ; - Searching for mapped documents in assembly: NHibernateStudy
2005-12-18 22:52:23,453 [2552] INFO  NHibernate.Cfg.Configuration [(null)] & ;(null)& ; - Found mapping documents in assembly: Tag.hbm.xml
2005-12-18 22:52:23,796 [2552] INFO  NHibernate.Dialect.Dialect [(null)] & ;(null)& ; - Using dialect: NHibernate.Dialect.MsSql2000Dialect
2005-12-18 22:52:23,843 [2552] INFO  NHibernate.Cfg.Binder [(null)] & ;(null)& ; - Mapping class: NHibernateStudy.DAL.Tag -> Tag
2005-12-18 22:52:23,890 [2552] ERROR NHibernate.Cfg.Configuration [(null)] & ;(null)& ; - Could not compile the mapping document
NHibernate.MappingException: associated class not found: NHibernateStudy.DAL.Tag , NHibernateStudy ---> System.TypeLoadException: 未能从程序集 NHibernateStudy 中加载类型 NHibernateStudy.DAL.Tag 。
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
   --- 内部异常堆栈跟踪的结尾 ---
   at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
   at NHibernate.Cfg.Binder.BindOneToMany(XmlNode node, OneToMany model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindCollection(XmlNode node, Collection model, String className, String path, Mappings mappings)
   at NHibernate.Cfg.CollectionTypeSet.Create(XmlNode node, String prefix, String path, PersistentClass owner, Mappings mappings)
   at NHibernate.Cfg.Binder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
   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)





????????????????????????????????


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 18, 2005 12:14 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
ChildTag should be a ISet (from Iesi.Collections)

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject: Change to ISet , but still error
PostPosted: Mon Dec 19, 2005 6:45 am 
Newbie

Joined: Sun Dec 18, 2005 10:22 am
Posts: 5
Change to ISet , but still error
really need some help , thanks

Code:
2005-12-19 18:40:40,343 [1804] ERROR NHibernate.Cfg.Configuration [(null)] & ;(null)& ; - Could not compile the mapping document
NHibernate.MappingException: associated class not found: NHibernateStudy.DTO.Tag , NHibernateStudy ---> System.TypeLoadException: 未能从程序集 NHibernateStudy 中加载类型 NHibernateStudy.DTO.Tag 。
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
   --- 内部异常堆栈跟踪的结尾 ---
   at NHibernate.Cfg.Binder.ClassForFullNameChecked(String fullName, String errorMessage)
   at NHibernate.Cfg.Binder.BindOneToMany(XmlNode node, OneToMany model, Mappings mappings)
   at NHibernate.Cfg.Binder.BindCollection(XmlNode node, Collection model, String className, String path, Mappings mappings)
   at NHibernate.Cfg.CollectionTypeSet.Create(XmlNode node, String prefix, String path, PersistentClass owner, Mappings mappings)
   at NHibernate.Cfg.Binder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
   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)



Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 7:59 am 
Newbie

Joined: Sun Dec 18, 2005 10:22 am
Posts: 5
KPixel i send you a mail about my code


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 8:24 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
You did a typo here:
Quote:
<class name="NHibernateStudy.DAL.Tag . NHibernateStudy" table="Tag" >


Note that if you keep doing this kind of errors, you might use NHibernate.Mapping.Attributes or ActiveRecord :wink:

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 5:09 am 
Newbie

Joined: Sun Dec 18, 2005 10:22 am
Posts: 5
The question solved.Thank you.

I finally altered to the hbm document like this
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" namespace="NHibernateStudy.DTO" assembly="NHibernateStudy">

<class name="Tag" table="Tag" >
   <id name="TagID" column="TagID" type="Int32" unsaved-value="0">
      <generator class="native" />
   </id>
   
   <property name="TagName" column="TagName" />

   <many-to-one name="ParentTag" class="Tag" column="ParentTagID" not-null="true" />
   <set name="ChildTag" inverse="true">
      <key column="ParentTagID" />
      <one-to-many class="Tag" />
   </set>

   <set name="ChildProduct">
      <key column="BelongTagID" />
      <one-to-many class="Product,NHibernateStudy" />
   </set>

</class>

</hibernate-mapping>


I think I will be able to attempt use NHibernate.Mapping.Attributes later.

thank you KPixel.


But now had the new problem again.
I am unable to carry on any inquiry on 'Tag', any inquiry all does not have the result.
Quote:
No row with the given identifier exists: 0,

I use ISession.Load method


Causes this question the reason is
Code:
   <many-to-one name="ParentTag" class="Tag" column="ParentTagID" not-null="true" />
   <set name="ChildTag" inverse="true">
      <key column="ParentTagID" />
      <one-to-many class="Tag" />
   </set>


becase i see the LOG , Inside has such one part
Quote:
SELECT tag0_.TagID as TagID1_, tag0_.TagName as TagName1_, tag0_.ParentTagID as ParentTa3_1_, tag1_.TagID as TagID0_, tag1_.TagName as TagName0_, tag1_.ParentTagID as ParentTa3_0_ FROM Tag tag0_ left outer join Tag tag1_ on tag0_.ParentTagID=tag1_.TagID WHERE tag0_.TagID=@p0


my Table structure is


TagID
TagName
ParentTagID



I am thinking that Nhibernate do not support this kind of structure???????

How realizes one tree's classics method is? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 2:54 am 
Newbie

Joined: Sun Dec 18, 2005 10:22 am
Posts: 5
Is my expression has not been clear??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.