Hibernate Books

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Retrieving data from database
PostPosted: Thu Feb 02, 2012 12:49 pm 
Newbie

Joined: Thu Feb 02, 2012 12:22 pm
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.