Hi everyone
I am having a problem whith NHIBERNATE
I am getting a list fom the database to populate a listbox in my system using the method bellow:
public IList<Processo> getProcessos()
{
IList<Processo> processos;
//Retorna todos os processos do banco de dados
processos = session.CreateQuery("from Processo").List<Processo>();
return processos;
}
The return value is a processo´s list
After the system save or update a 'processo' in the database to refresh the listbox whit the processo´s list, i call again the method getProcessos()
but i cant refresh the listbox, no matter how many times I insert a new processo or update the return of the method 'getProcessos()' is always the same, and i cant refresh my listbox
how i can solve this problem?
anyone can help me
sorry for the bad english, i need to practice more : )
thanks in advance
Hibernate version:
1.2 GA
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Add this element -->
<configSections>
<section
name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"
/>
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=MDDB04SP;initial catalog=DBSUM;User ID=usr_mddb04sp;Password=#jaera#;Min Pool Size=2</property>
<property name="ShowSql">true</property>
<mapping assembly="ProducaoMidiaMix" />
</session-factory>
</hibernate-configuration>
</configuration>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="ProducaoMidiaMix.Negocio" assembly="ProducaoMidiaMix">
<class name="Processo" table="SPMM_PROCESSO">
<composite-id name="Processokey" class="ProducaoMidiaMix.Negocio.Processo+ProcessoKey, ProducaoMidiaMix" unsaved-value="none" access="property">
<key-property name="CodigoProcesso" type="System.Int32" column="PROCESSO_COD" />
<key-property name="DataInicial" type="System.DateTime" column="PROCESSO_DATAINICIO" />
</composite-id>
<property name="DataFinal" type="System.DateTime" column="PROCESSO_DATAFIM" not-null="true" />
<property name="NomeProcesso" type="System.String" column="PROCESSO_NOME" not-null="true" length="100" />
<property name="TipoProcesso" type="System.Int32" column="PROCESSO_FLAGTIPO" not-null="true" />
<property name="TipoPeriodo" type="System.Int32" column="PROCESSO_FLAGTIPOPERIODO" not-null="true" length="100" />
<property name="PeriodoInicial" type="System.Int32" column="PROCESSO_PERIODOINICIAL" not-null="true" />
<property name="PeriodoFinal" type="System.Int32" column="PROCESSO_PERIODOFINAL" not-null="true" />
<property name="FlagImportar" type="System.Boolean" column="PROCESSO_FLAGIMPORTAR" not-null="false" />
<property name="FlagPonderar" type="System.Boolean" column="PROCESSO_FLAGPONDERAR" not-null="false" />
<property name="FlagExportar" type="System.Boolean" column="PROCESSO_FLAGEXPORTAR" not-null="false" />
<property name="FlagFusao" type="System.Boolean" column="PROCESSO_FLAGFUSAO" not-null="false" />
<property name="TipoProcessoRadio" type="System.Int32" column="PROCESSO_TIPORADIO" not-null="false" />
<property name="Usuario" type="System.String" column="USUARIO_NOME" not-null="true" length="100" />
<bag name="ListaTarefa" inverse="true" lazy="true" cascade="none">
<key>
<column name="PROCESSO_COD" not-null="true" />
<column name="PROCESSO_DATAINICIO" not-null="true" />
</key>
<one-to-many class="ProducaoMidiaMix.Negocio.Tarefa, ProducaoMidiaMix" />
</bag>
<filter name="ProcessoAtual"
condition=":dataProcesso BETWEEN PROCESSO_DATAINICIO and PROCESSO_DATAFIM"/>
</class>
<filter-def name="ProcessoAtual">
<filter-param name="dataProcesso" type="date"/>
</filter-def>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public static ISession getSession()
{
if (factory == null)
{
lock (typeof(NHibernateHelper))
{
XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
log.Info("Log4Net Configurado e Inicializado");
configuration = new Configuration();
configuration.Configure("hibernate.cfg.xml");
factory = configuration.BuildSessionFactory();
log.Info("Hibernate Iniciado e configurado");
session = factory.OpenSession();
}
}
return session;
}
Full stack trace of any exception that occurs:
Name and version of the database you are using:
SQL SERVER 2000
The generated SQL (show_sql=true):
2007-08-22 10:52:57,782 [1] INFO NHibernate.Loader.Loader.GetResultSet(:0) NHibernate.Loader.Loader - select processo0_.PROCESSO_COD as PROCESSO1_0_, processo0_.PROCESSO_DATAINICIO as PROCESSO2_0_, processo0_.PROCESSO_DATAFIM as PROCESSO3_0_, processo0_.PROCESSO_NOME as PROCESSO4_0_, processo0_.PROCESSO_FLAGTIPO as PROCESSO5_0_, processo0_.PROCESSO_FLAGTIPOPERIODO as PROCESSO6_0_, processo0_.PROCESSO_PERIODOINICIAL as PROCESSO7_0_, processo0_.PROCESSO_PERIODOFINAL as PROCESSO8_0_, processo0_.PROCESSO_FLAGIMPORTAR as PROCESSO9_0_, processo0_.PROCESSO_FLAGPONDERAR as PROCESSO10_0_, processo0_.PROCESSO_FLAGEXPORTAR as PROCESSO11_0_, processo0_.PROCESSO_FLAGFUSAO as PROCESSO12_0_, processo0_.PROCESSO_TIPORADIO as PROCESSO13_0_, processo0_.USUARIO_NOME as USUARIO14_0_ from SPMM_PROCESSO processo0_ where @p0 BETWEEN processo0_.PROCESSO_DATAINICIO and processo0_.PROCESSO_DATAFIM
|