Hi there.
I need help....
I have the follow code:
The class.
Code:
using System;
namespace RDestribBUS
{
public class UF
{
private int m_Id;
private string m_UF;
private string m_Descricao;
public virtual int Id
{
get
{
return m_Id;
}
}
public virtual string uf
{
get
{
return m_UF;
}
set
{
m_UF=value;
}
}
public virtual string Descricao
{
get
{
return m_Descricao;
}
set
{
m_Descricao = value;
}
}
}
}
The UF.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" >
<class name="RDestribBUS.UF, RDestribBUS" table="UF">
<id name="Id" type="Int32" column="UFId">
<generator class="native" />
</id>
<property name="uf" column="UF" type="String(2)" />
<property name="Descricao" column="Descricao" type="String(40)" />
</class>
</hibernate-mapping>
Code:
using System;
using NHibernate;
using NHibernate.Cfg;
using System.Collections;
namespace RDestribBUS
{
public class MUF
{
ISessionFactory factory;
Configuration config;
ISession session;
public MUF()
{
factory=config.BuildSessionFactory();
session=factory.OpenSession();
//SQL SERVER
props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
props["hibernate.dialect" ] = "NHibernate.Dialect.MsSql2000Dialect";
props["hibernate.connection.driver_class" ] = "NHibernate.Driver.SqlClientDriver" ;
props["hibernate.connection.connection_string"] = "Server=localhost;initial catalog=RDestrib;User ID=root;Password=123redhot" ;
foreach( DictionaryEntry de in props )
{
config.SetProperty( de.Key.ToString(), de.Value.ToString() );
}
config.AddAssembly("RDestribBUS");
factory = config.BuildSessionFactory();
session = factory.OpenSession();
}
public IList getUFs()
{
ITransaction tx=session.BeginTransaction();
IList uf;
uf=session.CreateCriteria(typeof(UF)).List();
return uf;
}
}
}
When I call getUFs() the follow error is displayed:
An unhandled exception of type 'NHibernate.PropertyAccessException' occurred in nhibernate.dll
Additional information: ArgumentException while setting the property value by reflection
Can you help me? I dont knwo what to do... :(