Hey, all!
I'm starting with NHibernate, and I'm having some troubles with it.
Well, this is my
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Ships.Domain.State, Ships.Domain" lazy="true" table="states">
<id name="ID" column="HANDLE" type="Int64">
</id>
<property name="Name" column ="NAME" type="String" />
<property name="Abreviation" column="ABREVIATION" type="String" />
</class>
</hibernate-mapping>
This is my State POCO class:
Code:
namespace Ships.Domain
{
public class State
{
public virtual long ID { get; set; }
public virtual string Name { get; set; }
public virtual string Abreviation { get; set; }
public override string ToString() {
return Name;
}
}
}
When I create a ISession object, I do it this way:
Code:
public ISession RetrieveSession()
{
if (entidadeSessionFactoryCampus == null) {
Configuration entidadeConfigurationCampus = new Configuration();
entidadeConfigurationCampus.SetProperty("dialect", "NHibernate.Dialect.Oracle10gDialect");
entidadeConfigurationCampus.SetProperty("connection.driver_class", "NHibernate.Driver.OracleClientDriver");
entidadeConfigurationCampus.SetProperty("connection.connection_string", "/*My Connection String */");
entidadeConfigurationCampus.AddAssembly("Ships.Domain");
entidadeSessionFactoryCampus = entidadeConfigurationCampus.BuildSessionFactory();
}
return entidadeSessionFactoryCampus.OpenSession();
}
When I try to retrieve a collection, the NHibernate returns me nothing, a empty collection.
Code:
static void Main()
{
ISession entidadeSession = NHibernateFactory.RetrieveSession();
ICriteria entidadeCriteria = entidadeSession.CreateCriteria(typeof(State));
IList ships = entidadeCriteria.List();
}
Anyone has any ideia about this problem?
Thanks all, God bless you!