-->
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.  [ 1 post ] 
Author Message
 Post subject: nhibernate: Architectura
PostPosted: Wed May 02, 2007 12:59 pm 
Newbie

Joined: Wed May 02, 2007 12:56 pm
Posts: 17
Hi
The way i use nhibernte is the following in a asp.net

I´ve got a NHIbernate HttpModule class that instanciate a sesion for request.I´ve a got a DAO for accessing each table. I´ve got a business manager over the dao class. I put an example:

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

using com.tinsa.utils.log;
using com.tinsa.utils.nhibernate;
using NHibernate;
namespace com.tinsa.db.dao
{
public class NivelesDAO
{
private static NivelesDAO nivelManager;

private static string className = "NivelesDAO";

public static NivelesDAO getInstance()
{
if (nivelManager == null)
{
nivelManager = new NivelesDAO();
}
return nivelManager;
}

public IList obtenerNiveles()
{
string localizator = "[" + className + ":obtenerNiveles]:";
try
{
ISession sesion = NHibernateHttpModule.CurrentSession;
IList resultList = sesion.CreateQuery("from Nivel").List();
return resultList;
}
catch (Exception e)
{
if (Log.IsErrorEnabled ())
Log.Error(localizator + "Error obteniendo los niveles de la Base de datos." + e.Message, e);
throw e;
}
}
}
}

My doubts are:

* Is it correct the gestinstance or i can delete it?
* I´ve i want to access to table in the same request how can i do that? Maybe i want to look in a table and them insert in another one:
public SLA calcularPrioridad(int urgencia, int usuarios, int degradacion, Incidencia incidencia)
{
string localizator = "[" + className + ":calcularPrioridad]:";
try
{
MatrizDAO matrizManager = MatrizDAO.getInstance();
Prioridad prioridadSalida = matrizManager.obtenerPrioridad(urgencia, usuarios, degradacion, incidencia.Proceso.Requisito);
incidencia.Prioridad = new Prioridad(prioridadSalida);
SLA sla = SLADAO.getInstance().obtenerSLA(prioridadSalida);
return sla;
}
Is that correct? But how can i do to that in the same transaction if the transaction is in the dao layer in not in the business layer?

Best regards


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.