-->
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.  [ 4 posts ] 
Author Message
 Post subject: could not insert
PostPosted: Wed Oct 26, 2005 10:41 am 
Newbie

Joined: Sun Oct 16, 2005 3:37 pm
Posts: 2
Hi all,

I need help
I have two class State and City



public class State
{


private int m_Id;
private string m_State;
private string m_Description


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

public virtual string State
{
get
{
return m_State;
}
set
{
m_Sate=value;
}
}

public virtual string Description
{
get
{
return m_description
}
set
{
M_description= value;
}
}
}




public class City
{

public City()
{
m_State=new State();
}

private System.Int32 m_Id;
private State m_state;
private System.String m_Name;

public virtual System.Int32 Id
{
get
{
return m_Id;
}
set
{
m_Id=value;
}
}

public virtual State State
{
get
{
return m_State;
}
set
{
m_State = value;
}
}

public virtual System.String Name
{
get
{
return m_Name
}
set
{
m_name= value;
}
}
}





<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
<class name="RDestribBUS.Sate, RDestribBUS" table="State">
<id name="Id" type="Int32" column="StateId">
<generator class="native" />
</id>
<property name="State" column="State" type="String(2)" />
<property name="Description" column="Description" type="String(40)" />
</class>
</hibernate-mapping>



<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
<class name="RDestribBUS.City, RDestribBUS" table="City">
<id name="Id" type="Int32" column="CityId">
<generator class="native" />
</id>
<one-to-one name="State" class="RDestribBUS.State, RDestribBUS" />
<property name="Name" column="Name" type="String(40)" />
</class>
</hibernate-mapping>




public System.Boolean saveCity(Cidade oCity
{
ITransaction tx;
try
{
session=factory.OpenSession();
tx=session.BeginTransaction();

session.SaveOrUpdate(oCity);

tx.Commit();
return true;
}


catch (Exception e)
{
//
return false;
}
}




Whem the method saveCidade is called the follow error is displayed
"could not insert: [RDestribBUS.Cidade]"

I dont know what to do....
can you help me? Please....
:)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 11:47 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
If you set your log4net logging level to DEBUG you'll get a whole lot of debug data. When your exception is thrown you should be able to see all of the inner exceptions that are thrown including the ADO.NET exception which should detail the reason the database refused to insert your record.

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 1:02 pm 
How can i use log4net ?


Top
  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 9:59 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Configuring log4net Logging
For even more information, go to log4net website...

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


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