My advice is to read through (N)Hibernate in Action in tandem with the
documentation to get a good feel of the main components of NHibernate. I
would still read through the best practices Tuna recommended on codeproject
(http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx).
Now that we have Burrow (http://nhforge.org/wikis/burrow/default.aspx), I
would definitely look into that, because it addresses session and
transaction management, which is likely to be the next hurdle you'll want to
cross, all with minimal effort on your part.

Burrow, burrow, burrow.

Hope this helps,

David

The link Tuna gave you will show u best practices for managing a session by
hand.

On Wed, Nov 19, 2008 at 4:04 PM, 8bit <[EMAIL PROTECTED]> wrote:

>
> Will the helper utility in the reference manual suffice?  And if so,
> is my "GetAllTags" method the proper way to use it?
>
>         Public Function GetAllTags() As IList(Of String)
>            Dim tags As IList(Of String) = Nothing
>            Dim session As ISession =
> Utility.NHibernateUtil.GetCurrentSession()
>
>            Try
>                 tags = session.CreateQuery("select t.Name from Tag t
> group by t.Name order by t.Name") _
>                .List(Of String)()
>            Finally
>                 Utility.NHibernateUtil.CloseSession()
>             End Try
>
>            Return tags
>        End Function
>
>
>      Private Const CurrentSessionKey As String =
> "nhibernate.current_session"
>        Private Shared sessionFactory As ISessionFactory
>
>        Shared Sub NHibernateUtil()
>            sessionFactory = New Configuration().Configure
> ().BuildSessionFactory()
>        End Sub
>
>        Public Shared Function GetCurrentSession() As ISession
>            Dim currentContext As HttpContext
>            currentContext = HttpContext.Current
>
>            Dim currentSession As ISession = currentContext.Items
> (CurrentSessionKey)
>
>            If currentSession Is Nothing Then
>                currentSession = sessionFactory.OpenSession()
>                currentContext.Items(CurrentSessionKey) =
> currentSession
>            End If
>
>            Return currentSession
>        End Function
>
>        Public Shared Sub CloseSession()
>            Dim currentContext As HttpContext
>            currentContext = HttpContext.Current
>
>            Dim currentSession As ISession = currentContext.Items
> (CurrentSessionKey)
>
>            If currentSession Is Nothing Then
>                Return
>            End If
>
>            currentSession.Close()
>            currentContext.Items.Remove(CurrentSessionKey)
>        End Sub
>
>        Public Shared Sub CloseSessionFactory()
>            If Not sessionFactory Is Nothing Then
>                sessionFactory.Close()
>            End If
>        End Sub
>
> On Nov 19, 8:49 am, "Fabio Maulo" <[EMAIL PROTECTED]> wrote:
> > 2008/11/19 Roger Kratz <[EMAIL PROTECTED]>
> >
> >
> >
> > > I got the impression that you recreate your IsessionFactory over and
> over
> > > again for each request/every call to your data layer? Creating an
> > > ISessionFactory is an expansive op. Create the instance in some start
> up
> > > code for your web app and reuse it.
> >
> > Roger... our friend 8bit (I don't know the name) are asking here,
> probably,
> > because he skip
> > 10.1. Configurations, Sessions and Factories
> > of the reference.
> > We are talking about how have better reference manual but... ;)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to