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.  [ 10 posts ] 
Author Message
 Post subject: "Input string was not in a correct format" w/ Comp
PostPosted: Wed Sep 27, 2006 5:04 pm 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:03 pm
Posts: 22
Hibernate version:
NHibernate 1.0.2

I have 2 classes (A,B), with these mappings:
Code:
Class A
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Map.A,Map" table="tabA" lazy="false">
    <composite-id access="field">
      <key-property name="Id" column="id" type="String" />
      <key-property name="Idlt" column="idlt" type="Int32" />
    </composite-id>
....
  </class>
</hibernate-mapping>


Code:
Class B
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="Map.B,Map" table="tabB" lazy="false">
<id name="Id" column="id" type="Int32" unsaved-value="0">
      <generator class="assigned"/>
    </id>   
   
    <many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="idlt" />
      <column name="id"/>
    </many-to-one>


So, when I trie to Load "B" object I got the error "Input string was not in a correct format".
"could not load an entity: [Map.B#10000]"} System.Exception {NHibernate.ADOException}


Help?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 6:14 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
It looks like the types in your objects differ from the types in the mapping/database.

Can you turn on logging and post the SQL that is being prepared?

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 9:20 am 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:03 pm
Posts: 22
subdigital wrote:
It looks like the types in your objects differ from the types in the mapping/database.

Can you turn on logging and post the SQL that is being prepared?


Here my sql:

Code:
SELECT b_.id as identifi1_1_,  b_.idlt as idlt6_1_,  b_.id as idtabcad3_6_1_,  a_.id as idtabcad1_0_,  a_.idlt as idlt0_
FROM
tabB b_ left outer join tabA a_ on b_.idlt=a_.id and b_.id=a_.idlt
WHERE b_.id=:id


Help please


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 9:53 am 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:03 pm
Posts: 22
I know the problem is with that, because when I take off that mapping, everthing goes ok !

Code:
<many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="idlt" />
      <column name="id"/>
    </many-to-one>

[/code]

My C# on Class B is:
Code:
private A aObj;

public virtual A AObj
      {
         get { return aObj; }

         set   
         {
                aObj= value;
         }
      }



Help![/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 10:00 am 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
Hrm... that doesn't help. What do your classes look like?

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 10:10 am 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:03 pm
Posts: 22
subdigital wrote:
Hrm... that doesn't help. What do your classes look like?


Not special at all:

Class A
Code:
[Serializable]
    public class A
    {
        protected int idlt;
        protected string id;
        ....

    public virtual string Id
        {
            get { return id; }

            set
            {
                id= value;
            }
        }

   public virtual int Idlt
        {
            get { return idlt; }
            set
            {
                idlt = value;
            }

        }
...}


Class B
Code:
[Serializable]
    public class B
    {
private A aObj;
private int id;

public virtual A AObj
      {
         get { return aObj; }

         set   
         {
                aObj= value;
         }
      }
public virtual int Id
      {
         get { return id; }
         set
         {
            id = value;
         }

      }

}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 10:29 am 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
I'll have to dig into this later (at home). In the meantime you might try including the nhibernate source so that you can step through and see exactly what's going on.

This technique has helped me identify 2 issues with my project.

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:00 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
demol wrote:
Code:
<many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="idlt" />
      <column name="id"/>
    </many-to-one>



Maybe You should switch the order:

Code:
<many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="id"/>
      <column name="idlt" />
    </many-to-one>


as in A map they are in that order

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 12:12 pm 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:03 pm
Posts: 22
gert wrote:
demol wrote:
Code:
<many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="idlt" />
      <column name="id"/>
    </many-to-one>



Maybe You should switch the order:

Code:
<many-to-one name="AObj" class="Map.A,Map" unique="true" update="false" insert="false">
      <column name="id"/>
      <column name="idlt" />
    </many-to-one>


as in A map they are in that order

Gert


WOW ! Thats IT ! Works great now ! Stupid mistake ^^
Thank you Gert !

[]´s


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 1:17 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
Yeah good find. I totally missed that.

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


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