diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/Common.Logging.Log4Net.dll b/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/Common.Logging.Log4Net.dll new file mode 100644 index 00000000..3900bb87 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/Common.Logging.Log4Net.dll differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/log4net.dll b/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/log4net.dll new file mode 100644 index 00000000..ffc57e11 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/log4net.dll differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/Dao.xml b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/Dao.xml index 312bbfcc..013eda1d 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/Dao.xml +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/Dao.xml @@ -15,9 +15,9 @@ + connectionString="Data Source=(local);Integrated Security=true;User Instance=true;AttachDBFilename=|DataDirectory|\Northwnd.mdf"/> - + @@ -26,16 +26,10 @@ - - - - - - - + + + + @@ -46,26 +40,20 @@ + type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate21"> - - - - - - - + - + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs index 69f5e43e..799bbe6b 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs @@ -20,10 +20,8 @@ #region Imports - -using System.Collections; - -using Spring.Data.NHibernate.Support; +using System.Collections.Generic; +using Spring.Stereotype; using Spring.Transaction.Interceptor; using Spring.Northwind.Domain; @@ -32,16 +30,19 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao.NHibernate { - public class HibernateCustomerDao : HibernateDaoSupport, ICustomerDao + [Repository] + public class HibernateCustomerDao : HibernateDao, ICustomerDao { - public Customer FindById(string customerId) + [Transaction(ReadOnly = true)] + public Customer Get(string customerId) { - return HibernateTemplate.Load(typeof (Customer), customerId) as Customer; + return Session.Get(customerId); } - public IList FindAll() + [Transaction(ReadOnly = true)] + public IList GetAll() { - return HibernateTemplate.LoadAll(typeof (Customer)); + return GetAll(); } // Note that the transaction demaraction is here only for the case when @@ -57,23 +58,21 @@ namespace Spring.Northwind.Dao.NHibernate // same settings as started from the transactional layer. [Transaction(ReadOnly = false)] - public Customer Save(Customer customer) + public string Save(Customer customer) { - HibernateTemplate.Save(customer); - return customer; + return (string) Session.Save(customer); } [Transaction(ReadOnly = false)] - public Customer SaveOrUpdate(Customer customer) + public void SaveOrUpdate(Customer customer) { - HibernateTemplate.SaveOrUpdate(customer); - return customer; + Session.SaveOrUpdate(customer); } [Transaction(ReadOnly = false)] public void Delete(Customer customer) { - HibernateTemplate.Delete(customer); + Session.Delete(customer); } } } \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateDao.cs new file mode 100644 index 00000000..24020ca7 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateDao.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using NHibernate; + +namespace Spring.Northwind.Dao.NHibernate +{ + /// + /// Base class for data access operations. + /// + public abstract class HibernateDao + { + private ISessionFactory sessionFactory; + + /// + /// Session factory for sub-classes. + /// + public ISessionFactory SessionFactory + { + protected get { return sessionFactory; } + set { sessionFactory = value; } + } + + /// + /// Get's the current active session. Uses + /// Open Session In View in the background. + /// + protected ISession Session + { + get { return sessionFactory.GetCurrentSession(); } + } + + protected IList GetAll() where T : class + { + ICriteria criteria = Session.CreateCriteria(); + return criteria.List(); + } + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs index ef805273..5046f3d2 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs @@ -21,7 +21,8 @@ #region Imports using System.Collections; - +using System.Collections.Generic; +using Spring.Data.NHibernate.Generic; using Spring.Data.NHibernate.Support; using Spring.Northwind.Domain; @@ -30,34 +31,32 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao.NHibernate { - public class HibernateOrderDao : HibernateDaoSupport, IOrderDao + public class HibernateOrderDao : HibernateDao, IOrderDao { - public Order FindById(int orderId) + public Order Get(int orderId) { - return HibernateTemplate.Load(typeof(Order), orderId) as Order; + return Session.Get(orderId); } - public IList FindAll() + public IList GetAll() { - return HibernateTemplate.LoadAll(typeof(Order)); + return GetAll(); } - public Order Save(Order order) + public int Save(Order order) { - HibernateTemplate.Save(order); - return order; + return (int) Session.Save(order); } - public Order SaveOrUpdate(Order order) + public void SaveOrUpdate(Order order) { - HibernateTemplate.SaveOrUpdate(order); - return order; + Session.SaveOrUpdate(order); } public void Delete(Order order) { - HibernateTemplate.Delete(order); + Session.Delete(order); } } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs index a51a2631..f1922c92 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs @@ -21,7 +21,7 @@ #region Imports using System.Collections; - +using System.Collections.Generic; using Spring.Data.NHibernate.Support; using Spring.Northwind.Domain; @@ -30,34 +30,32 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao.NHibernate { - public class HibernateProductDao : HibernateDaoSupport, IProductDao + public class HibernateProductDao : HibernateDao, IProductDao { - public Product FindById(int productId) + public Product Get(int productId) { - return HibernateTemplate.Load(typeof(Product), productId) as Product; + return Session.Get(productId); } - public IList FindAll() + public IList GetAll() { - return HibernateTemplate.LoadAll(typeof(Product)); + return GetAll(); } - public Product Save(Product product) + public int Save(Product product) { - HibernateTemplate.Save(product); - return product; + return (int) Session.Save(product); } - public Product SaveOrUpdate(Product product) + public void SaveOrUpdate(Product product) { - HibernateTemplate.SaveOrUpdate(product); - return product; + Session.SaveOrUpdate(product); } public void Delete(Product product) { - HibernateTemplate.Delete(product); + Session.Delete(product); } } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj index 01147954..74f1729c 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj @@ -32,29 +32,21 @@ False ..\..\..\..\..\lib\net\2.0\antlr.runtime.dll - - False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Castle.DynamicProxy.dll - False ..\..\..\..\..\bin\net\2.0\debug\Common.Logging.dll - - False - ..\..\..\..\..\bin\net\2.0\debug\Common.Logging.Log4Net.dll - False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Iesi.Collections.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll False - ..\..\..\..\..\lib\NHibernate12\net\2.0\log4net.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\log4net.dll False - ..\..\..\..\..\lib\NHibernate12\net\2.0\NHibernate.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\NHibernate.dll False @@ -64,9 +56,9 @@ False ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.dll - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate12.dll + ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate21.dll @@ -76,6 +68,7 @@ Code + Code diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs index 020ae10e..35bcc6f3 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs @@ -21,19 +21,14 @@ #region Imports using System.Collections; - +using System.Collections.Generic; using Spring.Northwind.Domain; #endregion namespace Spring.Northwind.Dao { - public interface ICustomerDao + public interface ICustomerDao : IDao, ISupportsDeleteDao, ISupportsSave { - Customer FindById(string customerId); - IList FindAll(); - Customer Save(Customer customer); - Customer SaveOrUpdate(Customer customer); - void Delete(Customer customer); } } \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs new file mode 100644 index 00000000..a816c18b --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace Spring.Northwind.Dao +{ + public interface IDao + { + /// + /// Finds entity with given id. + /// + /// The id to search with. + /// Found entity or null if not found. + TEntity Get(TId id); + + /// + /// Returns all entities of given type. + /// The result may be different than in database based on + /// filters or other locked search criteria for search. + /// + /// + IList GetAll(); + + + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs index c269a700..2eb70993 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs @@ -28,12 +28,10 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao { - public interface IOrderDao + public interface IOrderDao : IDao, ISupportsDeleteDao { - Order FindById(int orderId); - IList FindAll(); - Order Save(Order order); - Order SaveOrUpdate(Order order); - void Delete(Order order); + int Save(Order order); + + void SaveOrUpdate(Order order); } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs index 7a830e57..e0507aaa 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs @@ -28,12 +28,8 @@ using Spring.Northwind.Domain; namespace Spring.Northwind.Dao { - public interface IProductDao + public interface IProductDao : IDao, ISupportsDeleteDao, ISupportsSave { - Product FindById(int productId); - IList FindAll(); - Product Save(Product product); - Product SaveOrUpdate(Product product); - void Delete(Product product); + } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs new file mode 100644 index 00000000..057cba87 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsDeleteDao.cs @@ -0,0 +1,7 @@ +namespace Spring.Northwind.Dao +{ + public interface ISupportsDeleteDao + { + void Delete(TEntity entity); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs new file mode 100644 index 00000000..a40b3093 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs @@ -0,0 +1,18 @@ +namespace Spring.Northwind.Dao +{ + public interface ISupportsSave + { + /// + /// Saves the given entity. + /// + /// Entity to save. + /// The id for saved entity. + TId Save(TEntity entity); + + /// + /// Saves or updates the entity. Behavior depends on the current state of entity's ID. + /// + /// Entity to save or update. + void SaveOrUpdate(TEntity entity); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Spring.Northwind.Dao.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Spring.Northwind.Dao.csproj index 89089ccb..f34633b5 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Spring.Northwind.Dao.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Spring.Northwind.Dao.csproj @@ -32,8 +32,11 @@ + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs index fc81bbae..e5f1fa59 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs @@ -82,7 +82,7 @@ namespace Spring.Northwind.Service public void ProcessCustomer(string customerId) { //Find all orders for customer - Customer customer = CustomerDao.FindById(customerId); + Customer customer = CustomerDao.Get(customerId); foreach (Order order in customer.Orders) { diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Antlr3.Runtime.dll b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Antlr3.Runtime.dll new file mode 100644 index 00000000..637fc3e3 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Antlr3.Runtime.dll differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/LinFu.DynamicProxy.dll b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/LinFu.DynamicProxy.dll new file mode 100644 index 00000000..22225220 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/LinFu.DynamicProxy.dll differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/NHibernate.ByteCode.LinFu.dll b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/NHibernate.ByteCode.LinFu.dll new file mode 100644 index 00000000..015189d9 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/NHibernate.ByteCode.LinFu.dll differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Spring.Northwind.Web.References.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Spring.Northwind.Web.References.csproj index ec273d2c..3f2ed6d1 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Spring.Northwind.Web.References.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/Spring.Northwind.Web.References.csproj @@ -32,9 +32,9 @@ False ..\..\..\..\..\bin\net\2.0\debug\antlr.runtime.dll - + False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Castle.DynamicProxy.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\Antlr3.Runtime.dll False @@ -42,19 +42,27 @@ False - ..\..\..\..\..\lib\net\2.0\Common.Logging.Log4Net.dll + ..\..\lib\net\2.0\Common.Logging.Log4Net.dll - + False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Iesi.Collections.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll + + + False + ..\..\..\..\..\lib\NHibernate21\net\2.0\LinFu.DynamicProxy.dll False - ..\..\..\..\..\lib\NHibernate12\net\2.0\log4net.dll + ..\..\lib\net\2.0\log4net.dll - + False - ..\..\..\..\..\lib\NHibernate12\net\2.0\NHibernate.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\NHibernate.dll + + + False + ..\..\..\..\..\lib\NHibernate21\net\2.0\NHibernate.ByteCode.LinFu.dll False @@ -64,10 +72,6 @@ False ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.dll - - False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate12.dll - False ..\..\..\..\..\bin\net\2.0\debug\Spring.Web.dll diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/ICustomerEditController.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/ICustomerEditController.cs index ef71ca72..260f716a 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/ICustomerEditController.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/ICustomerEditController.cs @@ -2,7 +2,7 @@ using Spring.Northwind.Domain; public interface ICustomerEditController { - void EditCustomer(Customer customer); - void Clear(); - Customer CurrentCustomer { get; } + void EditCustomer(Customer customer); + void Clear(); + Customer CurrentCustomer { get; } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/NHibernateCustomerEditController.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/NHibernateCustomerEditController.cs index 3eb95704..3a21b65a 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/NHibernateCustomerEditController.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Code/NHibernateCustomerEditController.cs @@ -1,5 +1,3 @@ - -using System.Web; using NHibernate; using Spring.Data.NHibernate; using Spring.Northwind.Domain; @@ -7,42 +5,38 @@ using Spring.Northwind.Domain; /// /// /// erich.eichinger -/// $Id: NHibernateCustomerEditController.cs,v 1.1 2007/09/29 21:32:09 oakinger Exp $ -public class NHibernateCustomerEditController:ICustomerEditController +public class NHibernateCustomerEditController : ICustomerEditController { - private readonly ISessionFactory sessionFactory; - private Customer currentCustomer; + private readonly ISessionFactory sessionFactory; + private Customer currentCustomer; - public NHibernateCustomerEditController(ISessionFactory sessionFactory) - { - this.sessionFactory = sessionFactory; - } - - private ISession Session - { - get + public NHibernateCustomerEditController(ISessionFactory sessionFactory) { - return SessionFactoryUtils.GetSession( sessionFactory,false ); + this.sessionFactory = sessionFactory; } - } - public void EditCustomer(Customer customer) - { - currentCustomer = customer; - } - - public void Clear() - { - currentCustomer = null; - } - - public Customer CurrentCustomer - { - get + private ISession Session { - Customer customer = currentCustomer; - Session.Lock(customer, LockMode.None); - return customer; + get { return sessionFactory.GetCurrentSession(); } + } + + public void EditCustomer(Customer customer) + { + currentCustomer = customer; + } + + public void Clear() + { + currentCustomer = null; + } + + public Customer CurrentCustomer + { + get + { + Customer customer = currentCustomer; + Session.Lock(customer, LockMode.None); + return customer; + } } - } } diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF index e021679d..ec83fded 100644 Binary files a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND.MDF differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf index c8a53a48..fcbbdf4a 100644 Binary files a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/App_Data/NORTHWND_log.ldf differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css new file mode 100644 index 00000000..8314f473 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CSS/style.css @@ -0,0 +1,129 @@ +body { + margin: 0px; + padding: 0px; + background-color: #dfeac1; + text-align: center; +} + +.logo { + position:relative; + top:-8px; + left:22px; + float:left; +} + +#ad { + float:right; + position:relative; + right: 22px; + top:-8px; +} + + + +.navigation { + position:relative; + left: 25px; + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #000000; + text-decoration: none; + width:150px; +} +.navigation a, .navigation a:active, .navigation a:visited { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #7E7E7E; + text-decoration: none; +} +.navigation a:hover { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #000000; + text-decoration: none; +} + + +h4.navbar { + position:relative; + left: 0px; + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #5F5F5F; + text-decoration: none; + margin-bottom: 2px; +} +h1 { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 14px; + font-weight: normal; + color: #90A720; +} +a, a:active, a:visited { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; + text-decoration: underline; +} +a:hover { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #000000; +} +b { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + font-weight: bold; + color: #606060; +} +i { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; +} + +table { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; +} +.news { + border: 1px solid; + border-color: #C9C9C9; + padding: 12px; + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + color: #606060; + background-color: #F5F5F5; + margin-top: 20px; + margin-bottom: 20px; +} +.news b { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 11px; + font-weight: normal; + color: #90A720; +} +.news u { + font-family: Verdana, Arial, Helvetica, sans; + font-size: 12px; + font-weight: bold; + color: #606060; + text-decoration: none; +} +li { + margin-bottom: 12px; +} + +li.newslist { + margin-bottom: 2px; +} + +ul.newslist { + margin-left: 10px; + margin-top: 10px; +} +ul { + margin-left: 25px; + margin-top: 10px; +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx index 2fd7b637..63ff4870 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerEditor.aspx @@ -1,21 +1,23 @@ -<%@ Page Language="C#" CodeFile="CustomerEditor.aspx.cs" Inherits="CustomerEditor" %> - +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerEditor.aspx.cs" + Inherits="CustomerEditor" %> - - - Untitled Page - - -
-
- - - - -
ID:
Contact:
-
-
- - - - + + + + + + + + + + + +
+ ID: +
+ Contact: +
+
+ +
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx index 9ac91a23..f38883b0 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx @@ -1,14 +1,8 @@ -<%@ Page Language="C#" CodeFile="CustomerList.aspx.cs" Inherits="CustomerList" %> +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerList.aspx.cs" Inherits="CustomerList" %> <%@ Reference page="CustomerEditor.aspx" %> - - - - Untitled Page - - -
-
+ + - + + <%# Eval("ContactName")%> + - -
-
- - + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx.cs index 80bddf85..af51a621 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerList.aspx.cs @@ -54,7 +54,7 @@ public partial class CustomerList : Spring.Web.UI.Page private void Page_InitializeControls(object sender, EventArgs e) { // create/initialize controls here - customerList.DataSource = customerDao.FindAll(); + customerList.DataSource = customerDao.GetAll(); customerList.ItemCommand+=new DataGridCommandEventHandler(CustomerList_ItemCommand); customerList.PageIndexChanged+=new DataGridPageChangedEventHandler(CustomerList_PageIndexChanged); if (!IsPostBack) diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx index 68c91bc3..50a7b9fd 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerOrders.aspx @@ -1,32 +1,14 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomerOrders.aspx.cs" Inherits="CustomerOrders" %> - - - - - - Untitled Page - - -
-
- - +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" + CodeFile="CustomerOrders.aspx.cs" Inherits="CustomerOrders" %> + + + - - - - - -
-
- - + + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx new file mode 100644 index 00000000..71cf3653 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx @@ -0,0 +1,25 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerEditor.aspx.cs" + Inherits="CustomerEditor" %> + + + +
+ + + + + + + + + +
+ ID: +
+ Contact: +
+
+
+ +
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs new file mode 100644 index 00000000..7e958131 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/CustomerView.aspx.cs @@ -0,0 +1,65 @@ +using System; +using System.Web; +using Spring.Northwind.Dao; +using Spring.Northwind.Domain; +using Spring.Web.UI; + +public partial class CustomerView : Page +{ + private ICustomerEditController customerEditController; + private ICustomerDao customerDao; + + public ICustomerDao CustomerDao + { + set { this.customerDao = value; } + } + + public ICustomerEditController CustomerEditController + { + set { this.customerEditController = value; } + } + + public Customer CurrentCustomer + { + get { return customerEditController.CurrentCustomer; } + } + + // public static void Edit( Customer customer ) + // { + // HttpContext.Current.Session[typeof(CustomerEditor).FullName + ".Customer"] = customer; + // } + + public CustomerView() + { + this.InitializeControls += new EventHandler(Page_InitializeControls); + this.DataBound += new EventHandler(Page_DataBound); + this.DataUnbound += new EventHandler(Page_DataUnbound); + } + + override protected void InitializeDataBindings() + { + base.InitializeDataBindings(); + + // do the "one time" setup for databinding + } + + private void Page_DataBound(object sender, EventArgs e) + { + // perform custom tasks for binding data from model to the form + } + + private void Page_DataUnbound(object sender, EventArgs e) + { + // perform custom tasks for unbinding data from form to the model + } + + private void Page_InitializeControls(object sender, EventArgs e) + { + btnSave.Click += new EventHandler(BtnSave_Click); + } + + private void BtnSave_Click(object sender, EventArgs e) + { + customerDao.SaveOrUpdate(CurrentCustomer); + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx.cs index efeb8c9a..1ee22fc0 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Default.aspx.cs @@ -29,7 +29,7 @@ public partial class _Default : Spring.Web.UI.Page string customerId = "ERNSH"; // check, if exists - Customer customer = customerDao.FindById(customerId); + Customer customer = customerDao.Get(customerId); //Find all orders for customer and ship them this.fulfillmentService.ProcessCustomer(customer.Id); diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/header-spring.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/header-spring.png new file mode 100644 index 00000000..c112ff2a Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/header-spring.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/logo.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/logo.png new file mode 100644 index 00000000..8236a42a Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/logo.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/springNet_release.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/springNet_release.png new file mode 100644 index 00000000..a2f9f65c Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Img/springNet_release.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master new file mode 100644 index 00000000..8e9ea2f4 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master @@ -0,0 +1,59 @@ +<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="Shared_MasterPage" %> + + + + Spring.NET NHibernate Northwind Example + + + +
+
+ + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + +
+
+
+
+ + + + + +
+
+
+
+
+
+
+
+ + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master.cs new file mode 100644 index 00000000..fe86ea4c --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Shared/MasterPage.master.cs @@ -0,0 +1,9 @@ +using System; + +public partial class Shared_MasterPage : System.Web.UI.MasterPage +{ + protected void Page_Load(object sender, EventArgs e) + { + + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config index 11a3930d..883c8916 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Web.config @@ -55,7 +55,7 @@ - + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs index 538e6f74..c45316a2 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/IntegrationTests/NorthwindIntegrationTests.cs @@ -74,13 +74,13 @@ namespace Spring.Northwind.IntegrationTests [Test] public void CustomerDaoTests() { - Assert.AreEqual(91, customerDao.FindAll().Count); + Assert.AreEqual(91, customerDao.GetAll().Count); Customer c = new Customer(); c.Id = "MPOLL"; c.CompanyName = "Interface21"; customerDao.Save(c); - c = customerDao.FindById("MPOLL"); + c = customerDao.Get("MPOLL"); Assert.AreEqual(c.Id, "MPOLL"); Assert.AreEqual(c.CompanyName, "Interface21"); @@ -95,13 +95,13 @@ namespace Spring.Northwind.IntegrationTests customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers"); Assert.AreEqual(92, customerCount); - Assert.AreEqual(92, customerDao.FindAll().Count); + Assert.AreEqual(92, customerDao.GetAll().Count); c.CompanyName = "SpringSource"; customerDao.SaveOrUpdate(c); - c = customerDao.FindById("MPOLL"); + c = customerDao.Get("MPOLL"); Assert.AreEqual(c.Id, "MPOLL"); Assert.AreEqual(c.CompanyName, "SpringSource"); @@ -114,7 +114,7 @@ namespace Spring.Northwind.IntegrationTests try { - c = customerDao.FindById("MPOLL"); + c = customerDao.Get("MPOLL"); Assert.Fail("Should have thrown HibernateObjectRetrievalFailureException when finding customer with Id = MPOLL"); } catch (HibernateObjectRetrievalFailureException e) @@ -127,16 +127,16 @@ namespace Spring.Northwind.IntegrationTests [Test] public void ProductDaoTests() { - Assert.AreEqual(830, orderDao.FindAll().Count); + Assert.AreEqual(830, orderDao.GetAll().Count); Order order = new Order(); - Customer customer = customerDao.FindById("PICCO"); + Customer customer = customerDao.Get("PICCO"); order.Customer = customer; order.ShipCity = "New York"; orderDao.Save(order); int orderId = order.Id; - order = orderDao.FindById(orderId); + order = orderDao.Get(orderId); Assert.AreEqual("PICCO", order.Customer.Id); Assert.AreEqual("New York", order.ShipCity); @@ -146,12 +146,12 @@ namespace Spring.Northwind.IntegrationTests int ordersCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Orders"); Assert.AreEqual(831, ordersCount); - Assert.AreEqual(831, orderDao.FindAll().Count); + Assert.AreEqual(831, orderDao.GetAll().Count); order.ShipCity = "Sao Paulo"; orderDao.SaveOrUpdate(order); - order = orderDao.FindById(orderId); + order = orderDao.Get(orderId); Assert.AreEqual("PICCO", order.Customer.Id); Assert.AreEqual("Sao Paulo", order.ShipCity); @@ -166,7 +166,7 @@ namespace Spring.Northwind.IntegrationTests try { - order = orderDao.FindById(orderId); + order = orderDao.Get(orderId); Assert.Fail("Should have thrown HibernateObjectRetrievalFailureException when finding order with Id = " + orderId); } catch (HibernateObjectRetrievalFailureException e) diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/Spring.Northwind.IntegrationTests.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/Spring.Northwind.IntegrationTests.csproj index 33a76e1e..acd7b3a9 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/Spring.Northwind.IntegrationTests.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/test/Spring.Northwind.IntegrationTests/Spring.Northwind.IntegrationTests.csproj @@ -32,29 +32,21 @@ False ..\..\..\..\..\lib\Net\2.0\antlr.runtime.dll
- - False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Castle.DynamicProxy.dll - False ..\..\..\..\..\lib\Net\2.0\Common.Logging.dll - - False - ..\..\..\..\..\bin\net\2.0\debug\Common.Logging.Log4Net.dll - False - ..\..\..\..\..\lib\NHibernate12\net\2.0\Iesi.Collections.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll False - ..\..\..\..\..\lib\NHibernate12\net\2.0\log4net.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\log4net.dll False - ..\..\..\..\..\lib\NHibernate12\net\2.0\NHibernate.dll + ..\..\..\..\..\lib\NHibernate21\net\2.0\NHibernate.dll False @@ -68,9 +60,9 @@ False ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.dll - + False - ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate12.dll + ..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate21.dll False