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.  [ 5 posts ] 
Author Message
 Post subject: NullReferenceException: I load Class from column holds NULL
PostPosted: Mon Oct 23, 2006 5:04 pm 
Newbie

Joined: Thu Jan 19, 2006 7:24 am
Posts: 17
I use NHibernate 1.2.0 Beta1

"System.NullReferenceException: Object reference not set to an instance of an object"

I get this ERROR when i try to load Entity Class from a table's column contains NULL value, this column's type is MySql Varchar;
however if the colums has some value , the entity class can be loaded without ERROR!

How should i do for this problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 2:58 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Create a simple test case (classes, mappings, code) and report it to JIRA.


Top
 Profile  
 
 Post subject: Re: NullReferenceException: I load Class from column holds
PostPosted: Tue Oct 24, 2006 5:00 pm 
Contributor
Contributor

Joined: Tue May 30, 2006 1:25 am
Posts: 29
treebhoph wrote:
How should i do for this problem?


I think the problem is in your class.

Try this:

Mapping:
Code:
   <class name="A">
      <id name="Id" column="Id" type="Int32">
         <generator class="native"/>
      </id>
      <property name="Name"/>
   </class>



Class:
Code:
   public class A
   {
      private int _id;
      public int Id
      {   
         get { return _id; }
         set { _id = value; }
      }

      private string _name;
      public string Name
      {
         get { return _name; }
         set { _name = value; }
      }   
   }


Test:
Code:
         A a = new A();
         int savedId;
         using (ISession s = OpenSession())
         {
            s.Save(a);
            savedId = a.Id;
            s.Flush();
         }
         a = null;
         using (ISession s = OpenSession())
         {
            a= s.Load<A>(savedId);
            Assert.IsNull(a.Name);
         }         


The test work fine.

Please, after try it comment the NH-770 so we can close it.

Bye

P.S. Please, don't post JIRA more than one time.

_________________
Fabio Maulo.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 26, 2006 2:35 pm 
Newbie

Joined: Thu Jan 19, 2006 7:24 am
Posts: 17
It still Error.. I just add Attached files contained class, mapping, code and a log file.

http://jira.nhibernate.org/browse/NH-772


The Error always arise when I try to load class form table's column contained Null, Column Type is Varchar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 26, 2006 3:15 pm 
Contributor
Contributor

Joined: Tue May 30, 2006 1:25 am
Posts: 29
treebhoph wrote:
It still Error.. I just add Attached files contained class, mapping, code and a log file.

http://jira.nhibernate.org/browse/NH-772


The Error always arise when I try to load class form table's column contained Null, Column Type is Varchar


Confirmed. The problem is in your class an not in NHb.
Next time please use this forum and post mapping and class implementation before create three JIRA.
Thanks.

_________________
Fabio Maulo.


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