Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every Body,
I'm using The CodeSmith Generator professional edition V5.05 with NHibernate Framework (VB.net)
I generate all my classes with no problems, but I want to understand what is the significance of using the ManagerObjects classes.
I have a EMPLOYEE table in my database ; after generation I obtain the following classes :
EMPLOYEE.vb , EMPLOYEEManager.vb and base classes.
So I can perform a saveOrUpdate transaction using 2 methods :

Method1 : Using the ManagerObjects classes

Dim managerFac As IManagerFactory = New ManagerFactory()
Try
                managerFac.GetEMPLOYEEManager.Session.BeginTransaction()
                managerFac.GetEMPLOYEEManager.SaveOrUpdate(CType(currentObject, EMPLOYEE))
                managerFac.GetEMPLOYEEManager.Session.CommitTransaction()
Catch ex As Exception
                managerFac.GetEMPLOYEEManager.Session.RollbackTransaction()
                MessageBox.Show(ex.Message)
End Try


Method2 : Without Using the ManagerObjects classes

Dim config As New NHibernate.Cfg.Configuration
Dim sessionFactory As NHibernate.ISessionFactory = config.Configure.BuildSessionFactory
Dim session As NHibernate.ISession
Dim transaction As NHibernate.ITransaction
Try
                ModuleApplication.session = sessionFactory.OpenSession()
                ModuleApplication.transaction = ModuleApplication.session.BeginTransaction()
                ModuleApplication.transaction.Begin()
                ModuleApplication.session.SaveOrUpdate(CType(currentObject, EMPLOYEE))
                ModuleApplication.transaction.Commit()
Catch ex As Exception
                ModuleApplication.transaction.Rollback()
                MessageBox.Show(ex.Message)
End Try


Please Help Me to understand what is the difference between those 2 methods, and what is the significance of using the ManagerObjects classes.
Thanks in advance Wink
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900