diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2008.sln b/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2008.sln index d89f19f2..4ea2f8f0 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2008.sln +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2008.sln @@ -9,7 +9,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Dao.NHiber EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.IntegrationTests.2008", "test\Spring.Northwind.IntegrationTests\Spring.Northwind.IntegrationTests.2008.csproj", "{2D0C5DF7-3BDB-44FB-BC1B-58E60B170BAD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Web", "src\Spring.Northwind.Web\Spring.Northwind.Web.2008.csproj", "{2967CA64-7352-46E3-89C0-6BB3A0A13FC1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Web.2008", "src\Spring.Northwind.Web\Spring.Northwind.Web.2008.csproj", "{2967CA64-7352-46E3-89C0-6BB3A0A13FC1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Web.ConvWA.2008", "src\Spring.Northwind.Web.ConvWA\Spring.Northwind.Web.ConvWA.2008.csproj", "{8DCDA20D-DF9F-4723-9649-BC6934B36DC4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -71,6 +73,16 @@ Global {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Any CPU.Build.0 = Release|Any CPU {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Debug|.NET.ActiveCfg = Debug|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Release|.NET.ActiveCfg = Release|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Release|Any CPU.Build.0 = Release|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2010.sln b/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2010.sln index 64aa54eb..03c3e02c 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2010.sln +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.2010.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +# Visual Web Developer Express 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Service.2010", "src\Spring.Northwind.Service\Spring.Northwind.Service.2010.csproj", "{9E15876F-E9E0-43B7-9874-B54F163757D6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Dao.2010", "src\Spring.Northwind.Dao\Spring.Northwind.Dao.2010.csproj", "{7F45EEA2-50AC-44E2-85A6-2FFB02E38C44}" @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Integratio EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Web.2010", "src\Spring.Northwind.Web\Spring.Northwind.Web.2010.csproj", "{2967CA64-7352-46E3-89C0-6BB3A0A13FC1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Northwind.Web.ConvWA.2010", "src\Spring.Northwind.Web.ConvWA\Spring.Northwind.Web.ConvWA.2010.csproj", "{8EEAB62E-DBAF-4C5F-9906-77B2A817F945}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|.NET = Debug|.NET @@ -71,6 +73,16 @@ Global {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Any CPU.Build.0 = Release|Any CPU {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {2967CA64-7352-46E3-89C0-6BB3A0A13FC1}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Debug|.NET.ActiveCfg = Debug|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Release|.NET.ActiveCfg = Release|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Release|Any CPU.Build.0 = Release|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE 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 index 3900bb87..519caa6e 100644 Binary files a/examples/Spring/Spring.Data.NHibernate.Northwind/lib/net/2.0/Common.Logging.Log4Net.dll 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/src/Spring.Northwind.Dao.NHibernate/Dao/DaoConvWA.xml b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/DaoConvWA.xml new file mode 100644 index 00000000..2db27c0b --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/DaoConvWA.xml @@ -0,0 +1,74 @@ + + + + + The Northwind object definitions for the Data Access Objects. + + + + + + + + + + + + + + + + Spring.Northwind.Dao.NHibernate + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.2008.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.2008.csproj index 68ff5706..6e130430 100644 --- a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.2008.csproj +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.2008.csproj @@ -95,6 +95,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/ICustomerEditController.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/ICustomerEditController.cs new file mode 100644 index 00000000..9ee8ad98 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/ICustomerEditController.cs @@ -0,0 +1,8 @@ +using Spring.Northwind.Domain; + +public interface ICustomerEditController +{ + void EditCustomer(Customer customer); + void Clear(); + Customer CurrentCustomer { get; } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/NHibernateCustomerEditController.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/NHibernateCustomerEditController.cs new file mode 100644 index 00000000..dd72166c --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Controller/NHibernateCustomerEditController.cs @@ -0,0 +1,46 @@ +using NHibernate; +using Spring.Data.NHibernate; +using Spring.Northwind.Domain; + +/// +/// +/// erich.eichinger +public class NHibernateCustomerEditController : ICustomerEditController +{ + private readonly ISessionFactory sessionFactory; + private Customer currentCustomer; + + public NHibernateCustomerEditController(ISessionFactory sessionFactory) + { + this.sessionFactory = sessionFactory; + } + + private ISession Session + { + get { return sessionFactory.GetCurrentSession(); } + } + + public void EditCustomer(Customer customer) + { + currentCustomer = customer; + } + + public void Clear() + { + currentCustomer = null; + } + + public Customer CurrentCustomer + { + get + { + Customer customer = currentCustomer; + + //since the Customer entity may have been retrieved from a prior request, we need to reattach it to the current session + // in order to support lazy-loading, etc. on the Customer + Session.Lock(customer, LockMode.None); + + return customer; + } + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/ConversationPage.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/ConversationPage.cs new file mode 100644 index 00000000..75fc7648 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/ConversationPage.cs @@ -0,0 +1,37 @@ +using System; +using System.Data; +using System.Configuration; +using System.Linq; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using Spring.ConversationWA; + +/// +/// Base classe for page's that suport conversation. +/// +public class ConversationPage : Spring.Web.UI.Page +{ + private IConversationState conversation = null; + /// + /// Converastion exposed to pages. + /// + public IConversationState Conversation + { + get { return conversation; } + set { conversation = value; } + } + + /// + /// Here start/resume conversation to reconnect the ISession. + /// + /// + protected override void OnInit(EventArgs e) + { + this.Conversation.StartResumeConversation(); + base.OnInit(e); + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx new file mode 100644 index 00000000..769500bb --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx @@ -0,0 +1,37 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" + Inherits="CustomerEditor" Codebehind="CustomerEditor.aspx.cs" %> + + +

+ Update customer information

+
+ +
+ Customer details + + + + + + + + + + + + +
+ ID: +
+ Contact: +
+
+
+
+
+ « Back to customer list | + Cancel edit » +
+
+
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.cs new file mode 100644 index 00000000..ece38b25 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.cs @@ -0,0 +1,71 @@ +using System; +using Spring.Northwind.Dao; +using Spring.Northwind.Domain; +using Spring.Web.UI; + +public partial class CustomerEditor : Page +{ + private ICustomerEditController customerEditController; + private ICustomerDao customerDao; + + public ICustomerDao CustomerDao + { + set { customerDao = value; } + } + + public ICustomerEditController CustomerEditController + { + set { customerEditController = value; } + } + + public Customer CurrentCustomer + { + get + { + return customerEditController.CurrentCustomer; + } + } + + public CustomerEditor() + { + InitializeControls += Page_InitializeControls; + DataBound += Page_DataBound; + DataUnbound += 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 += BtnSave_Click; + } + + private void BtnSave_Click(object sender, EventArgs e) + { + customerDao.Update(CurrentCustomer); + SetResult("ViewCustomer"); + } + protected void customerList_Click(object sender, EventArgs e) + { + SetResult("CustomerList"); + } + protected void cancel_Click(object sender, EventArgs e) + { + SetResult("CancelEdit"); + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.designer.cs new file mode 100644 index 00000000..1adfaefa --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerEditor.aspx.designer.cs @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class CustomerEditor { + + /// + /// btnSave control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button btnSave; + + /// + /// customerList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton customerList; + + /// + /// cancel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cancel; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx new file mode 100644 index 00000000..5ad12d5f --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx @@ -0,0 +1,55 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" Inherits="CustomerList" Codebehind="CustomerList.aspx.cs" %> +<%@ Reference page="CustomerEditor.aspx" %> + + + +

Customers in database

+ +

+ Below you can see all customers in the database paged to grid. + By clicking customer name you enter the details and edit information. + By clicking orders you can see all orders that customer has. Orders can + be in shipped state (they have shipped date) or they can be waiting for + shipment. You can ship orders that aren't shipped yet on the orders screen. +

+

+ The customer entity is created with Spring and injected with an ICustomerClassificationCalculator + which includes basic calculation algorithm that we can use to calculate customer's value to us. +

+
+ + + + + + + + + + + +
+
+ + + + + + + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.cs new file mode 100644 index 00000000..e45dbc25 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections; +using System.Web.UI.WebControls; +using Spring.Northwind.Dao; +using Spring.Northwind.Domain; +using System.Collections.Generic; +using System.Web.UI.HtmlControls; +using System.Web.UI; + +public partial class CustomerList : ConversationPage +{ + private ICustomerEditController customerEditController; + private ICustomerDao customerDao; + + public ICustomerDao CustomerDao + { + set { this.customerDao = value; } + } + + public ICustomerEditController CustomerEditController + { + set { this.customerEditController = value; } + } + + public Customer SelectedCustomer + { + get + { + return (Customer) this.customerList.SelectedItem.DataItem; + } + } + + public CustomerList() + { + 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 + } + + /// + /// List not attached. This page will make searching the database only once per conversation. + /// + private IList CustomersLoadedOncePerConvList + { + get + { + return (IList)this.Conversation["CustomersLoadedOncePerConvList"]; + } + set + { + this.Conversation["CustomersLoadedOncePerConvList"] = value; + } + } + + private void Page_InitializeControls(object sender, EventArgs e) + { + //searching the database only once per conversation. + if (this.CustomersLoadedOncePerConvList == null) + { + // create/initialize controls here + this.CustomersLoadedOncePerConvList = customerDao.GetAll(); + } + + customerList.DataSource = this.CustomersLoadedOncePerConvList; + customerList.ItemCommand+=new DataGridCommandEventHandler(CustomerList_ItemCommand); + customerList.PageIndexChanged+=new DataGridPageChangedEventHandler(CustomerList_PageIndexChanged); + if (!IsPostBack) + { + customerList.DataBind(); + } + else + { + customerList.ItemCreated+=new DataGridItemEventHandler(this.CustomerList_ItemCreated); + } + } + + private void CustomerList_PageIndexChanged(object source, DataGridPageChangedEventArgs e) + { + customerList.CurrentPageIndex = e.NewPageIndex; + customerList.DataBind(); + } + + private void CustomerList_ItemCommand(object source, DataGridCommandEventArgs e) + { + switch(e.CommandName) + { + case "ViewOrders": + case "ViewCustomer": + customerList.SelectedIndex = e.Item.ItemIndex; + customerEditController.EditCustomer(this.SelectedCustomer); + SetResult(e.CommandName); + break; + } + } + + private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e) + { + if(e.Item.DataSetIndex > -1) + { + e.Item.DataItem = ((IList) customerList.DataSource)[e.Item.DataSetIndex]; + } + } + + protected void BtnShowOrders_Click(object sender, EventArgs e) + { + Button BtnShowOrders = (Button)sender; + DataGridItem dgi = (DataGridItem)BtnShowOrders.NamingContainer; + DataGrid DtgCustomerOrderList = (DataGrid)dgi.FindControl("DtgCustomerOrderList"); + HtmlControl DivCustomerOrderList = (HtmlControl)dgi.FindControl("DivCustomerOrderList"); + if (BtnShowOrders.Text == "+") + { + //discovery index for Customer + int customerIndex; + customerIndex = (this.customerList.PageSize * this.customerList.CurrentPageIndex) + dgi.ItemIndex; + Customer customerFromLine = this.CustomersLoadedOncePerConvList[customerIndex]; + DtgCustomerOrderList.DataSource = customerFromLine.Orders; + DtgCustomerOrderList.DataBind(); + DtgCustomerOrderList.Visible = true; + DivCustomerOrderList.Visible = true; + //background-color:White; position:absolute; left:-180px. Positioning, just visual. + DivCustomerOrderList.Style[HtmlTextWriterStyle.BackgroundColor] = "White"; + DivCustomerOrderList.Style[HtmlTextWriterStyle.Position] = "absolute"; + DivCustomerOrderList.Style[HtmlTextWriterStyle.Left] = "-380px"; + + BtnShowOrders.Text = "-"; + } + else + { + DtgCustomerOrderList.Visible = false; + DivCustomerOrderList.Visible = false; + BtnShowOrders.Text = "+"; + } + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.designer.cs new file mode 100644 index 00000000..3a282ead --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerList.aspx.designer.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class CustomerList { + + /// + /// customerList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DataGrid customerList; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx new file mode 100644 index 00000000..00c1b2db --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx @@ -0,0 +1,36 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" Inherits="CustomerOrders" Codebehind="CustomerOrders.aspx.cs" %> + + + +

Orders for customer

+ +

+ On this screen you can see all orders that customer has. By clicking "Process Orders" you + can send service request to ship all unshipped orders for that customer. Behind the scenes + Spring.NET will begin service level transaction that propagates to DAO layer which then + automatically participates int the existing transaction. +

+ +
+ + + + + + + + + + + +

+ +

+
+ « Back to customer list +
+
+
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.cs new file mode 100644 index 00000000..61df7222 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections; +using System.Web.UI.WebControls; + +using NHibernate; + +using Spring.Northwind.Domain; + +public partial class CustomerOrders : ConversationPage +{ + private ICustomerEditController customerEditController; + + public ICustomerEditController CustomerEditController + { + set { customerEditController = value; } + } + + public Customer SelectedCustomer + { + get { return customerEditController.CurrentCustomer; } + } + + public CustomerOrders() + { + InitializeControls += Page_InitializeControls; + DataBound += Page_DataBound; + DataUnbound += Page_DataUnbound; + } + + protected override 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) + { + // create/initialize controls here + customerOrders.DataSource = SelectedCustomer.Orders; + customerName.Text = SelectedCustomer.CompanyName; + if (!IsPostBack) + { + customerOrders.DataBind(); + } + else + { + customerOrders.ItemCreated += CustomerList_ItemCreated; + } + } + + private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e) + { + if (e.Item.DataSetIndex > -1) + { + e.Item.DataItem = ((IList) customerOrders.DataSource)[e.Item.DataSetIndex]; + } + } + protected void customerList_Click(object sender, EventArgs e) + { + SetResult("CustomerList"); + } + protected void processOrders_Click(object sender, EventArgs e) + { + SetResult("ProcessOrders"); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.designer.cs new file mode 100644 index 00000000..05976a30 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerOrders.aspx.designer.cs @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class CustomerOrders { + + /// + /// customerName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal customerName; + + /// + /// customerOrders control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DataGrid customerOrders; + + /// + /// processOrders control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button processOrders; + + /// + /// customerList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton customerList; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx new file mode 100644 index 00000000..9d69542f --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx @@ -0,0 +1,32 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" + Inherits="CustomerView" Codebehind="CustomerView.aspx.cs" %> + + +
+ +
+ Customer details + + + + + + + + + +
+ ID: + <%= CurrentCustomer.Id %> +
+ Contact: + <%= CurrentCustomer.ContactName %> +
+
+
+
+ « Back to customer list | + Edit Customer » +
+
+
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.cs new file mode 100644 index 00000000..84452f82 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.cs @@ -0,0 +1,69 @@ +using System; +using System.Web; +using Spring.Northwind.Dao; +using Spring.Northwind.Domain; +using Spring.Web.UI; + +public partial class CustomerView : ConversationPage +{ + 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) + { + + } + + protected void customerList_Click(object sender, EventArgs e) + { + SetResult("CustomerList"); + } + protected void editCustomer_Click(object sender, EventArgs e) + { + SetResult("EditCustomer"); + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.designer.cs new file mode 100644 index 00000000..3d6cd23c --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/CustomerView.aspx.designer.cs @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class CustomerView { + + /// + /// panel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Spring.Web.UI.Controls.DataBindingPanel panel; + + /// + /// customerList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton customerList; + + /// + /// editCustomer control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton editCustomer; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx new file mode 100644 index 00000000..8095e6e7 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx @@ -0,0 +1,13 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" Inherits="_Default" Codebehind="Default.aspx.cs" %> + + + +

Welcome to Spring.NET Northwind sample application!

+ +

+This sample demostrates Spring.NET NHibernate integration and concepts. All data access is done using NHibernate and +all transactions are automatically handled by Spring.NET. +

+ +Proceed to customer listing » +
\ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.cs new file mode 100644 index 00000000..b273b41e --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.cs @@ -0,0 +1,53 @@ +using System; +using System.Diagnostics; +using Spring.Northwind.Dao; +using Spring.Northwind.Domain; +using Spring.Northwind.Service; + +public partial class _Default : ConversationPage +{ + private ICustomerDao customerDao; + private IFulfillmentService fulfillmentService; + + public IFulfillmentService FulfillmentService + { + set { this.fulfillmentService = value; } + } + + public ICustomerDao CustomerDao + { + set { this.customerDao = value; } + } + + protected void Button1_Click(object sender, EventArgs e) + { + ProcessCustomer(); + } + + public void ProcessCustomer() + { + string customerId = "ERNSH"; + + // check, if exists + Customer customer = customerDao.Get(customerId); + + //Find all orders for customer and ship them + this.fulfillmentService.ProcessCustomer(customer.Id); + //assertions.... + + // prepare for display - note that OrderDetails are loaded lazy here! + foreach (Order order in customer.Orders) + { + Debug.Assert(order.OrderDetails.Count > 0); + foreach(OrderDetail details in order.OrderDetails) + { + details.Quantity = details.Quantity - 1; + // do something here + } + } + } + protected void customerList_Click(object sender, EventArgs e) + { + SetResult("CustomerList"); + } +} \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.designer.cs new file mode 100644 index 00000000..34205d0b --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Default.aspx.designer.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class _Default { + + /// + /// customerList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton customerList; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx new file mode 100644 index 00000000..1b7a18ff --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx @@ -0,0 +1,20 @@ +<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" Inherits="FullfillmentResult" Codebehind="FulfillmentResult.aspx.cs" %> + +<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" + Namespace="System.Web.UI" TagPrefix="asp" %> + +

Order processing results

+ +

+ Below you can see the results from order fullfilment. +

+ +
+
+ +
+
+ « Back to customer order list +
+
+
diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.cs new file mode 100644 index 00000000..9cd8cb71 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.cs @@ -0,0 +1,65 @@ +using System; +using System.IO; + +using log4net.Appender; +using log4net.Core; +using log4net.Layout; +using log4net.Repository; + +using Spring.Northwind.Service; +using Spring.Web.UI; + +using LogManager=log4net.LogManager; + +public partial class FullfillmentResult : ConversationPage +{ + private IFulfillmentService fulfillmentService; + private ICustomerEditController customerEditController; + + public IFulfillmentService FulfillmentService + { + set { fulfillmentService = value; } + } + + public ICustomerEditController CustomerEditController + { + set { customerEditController = value; } + } + + protected void Page_Load(object sender, EventArgs e) + { + // gather log4net output with small hack to get results... + ILoggerRepository repository = LogManager.GetRepository(); + IAppender[] appenders = repository.GetAppenders(); + MemoryAppender appender = null; + foreach (IAppender a in appenders) + { + if (a is MemoryAppender) + { + // we found our appender to look results from + appender = a as MemoryAppender; + break; + } + } + + if (appender != null) + { + appender.Clear(); + fulfillmentService.ProcessCustomer(customerEditController.CurrentCustomer.Id); + LoggingEvent[] events = appender.GetEvents(); + StringWriter stringWriter = new StringWriter(); + PatternLayout layout = new PatternLayout("%date{HH:mm:ss} %-5level %logger{1}: %message
"); + foreach (LoggingEvent loggingEvent in events) + { + layout.Format(stringWriter, loggingEvent); + } + + results.Text = stringWriter.ToString(); + } + + } + protected void customerOrders_Click(object sender, EventArgs e) + { + SetResult("Back"); + } +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.designer.cs new file mode 100644 index 00000000..d45888dd --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/FulfillmentResult.aspx.designer.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class FullfillmentResult { + + /// + /// results control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label results; + + /// + /// customerOrders control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton customerOrders; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Global.asax b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Global.asax new file mode 100644 index 00000000..ff1b8a7e --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Global.asax @@ -0,0 +1,36 @@ +<%@ Application Language="C#" %> + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/bg-spring.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/bg-spring.png new file mode 100644 index 00000000..fdb377cd Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/bg-spring.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/footern.gif b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/footern.gif new file mode 100644 index 00000000..8375fea1 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/footern.gif differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/header-spring.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/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.ConvWA/Img/header-spring.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/logo.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/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.ConvWA/Img/logo.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Img/springNet_release.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/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.ConvWA/Img/springNet_release.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master new file mode 100644 index 00000000..4d24b77c --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master @@ -0,0 +1,45 @@ +<%@ Master Language="C#" AutoEventWireup="true" Inherits="Shared_MasterPage" Codebehind="MasterPage.master.cs" %> + + + + Spring.NET NHibernate Northwind Example + + + +
+ +
+
+ + + + + + + + + + + + +
+ +
+ Goes Northwind
with NHibernate +
+
+
+ + + +
+
+
+
+
+ + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master.cs new file mode 100644 index 00000000..fe86ea4c --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/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.ConvWA/Shared/MasterPage.master.designer.cs b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master.designer.cs new file mode 100644 index 00000000..bde2a7ed --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Shared/MasterPage.master.designer.cs @@ -0,0 +1,32 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.5448 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + + +public partial class Shared_MasterPage { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// content control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ContentPlaceHolder content; +} diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2008.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2008.csproj new file mode 100644 index 00000000..5a8403d6 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2008.csproj @@ -0,0 +1,238 @@ + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {8DCDA20D-DF9F-4723-9649-BC6934B36DC4} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Spring.Northwind.Web + Spring.Northwind.Web + v3.5 + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\bin\net\3.5\debug\Common.Logging.dll + + + False + ..\..\lib\net\2.0\Common.Logging.Log4Net.dll + + + False + ..\..\..\..\..\lib\NHibernate32\net\3.5\Iesi.Collections.dll + + + False + ..\..\lib\net\2.0\log4net.dll + + + False + ..\..\..\..\..\lib\NHibernate32\net\3.5\NHibernate.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.Aop.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.ConversationWA.NH32.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.Core.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.Data.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.Data.NHibernate32.dll + + + False + ..\..\..\..\..\bin\net\3.5\debug\Spring.Web.dll + + + + + 3.5 + + + 3.5 + + + False + ..\..\lib\net\2.0\System.Data.SQLite.DLL + + + 3.5 + + + 3.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ASPXCodeBehind + + + CustomerEditor.aspx + + + CustomerList.aspx + + + CustomerOrders.aspx + + + CustomerView.aspx + + + Default.aspx + + + FulfillmentResult.aspx + + + + + CustomerEditor.aspx + ASPXCodeBehind + + + CustomerList.aspx + ASPXCodeBehind + + + CustomerOrders.aspx + ASPXCodeBehind + + + CustomerView.aspx + ASPXCodeBehind + + + Default.aspx + ASPXCodeBehind + + + FulfillmentResult.aspx + ASPXCodeBehind + + + MasterPage.master + ASPXCodeBehind + + + MasterPage.master + + + + + + + + + + + {6E4F55A0-C281-4706-A08B-BDEC2D2FBDA4} + Spring.Northwind.Dao.NHibernate.2008 + + + {7F45EEA2-50AC-44E2-85A6-2FFB02E38C44} + Spring.Northwind.Dao.2008 + + + {9E15876F-E9E0-43B7-9874-B54F163757D6} + Spring.Northwind.Service.2008 + + + + + + + + + + + + + + + + + + + + False + True + 60934 + / + + + False + False + + + False + + + + + + copy "$(ProjectDir)Web.net30.config" "$(ProjectDir)Web.config" /Y + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2010.csproj b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2010.csproj new file mode 100644 index 00000000..2d65b1fb --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Spring.Northwind.Web.ConvWA.2010.csproj @@ -0,0 +1,235 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {8EEAB62E-DBAF-4C5F-9906-77B2A817F945} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Spring.Northwind.Web + Spring.Northwind.Web + v4.0 + + + 3.5 + + + false + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\bin\net\4.0\debug\Common.Logging.dll + + + False + ..\..\lib\net\2.0\Common.Logging.Log4Net.dll + + + False + ..\..\..\..\..\lib\NHibernate32\net\4.0\Iesi.Collections.dll + + + False + ..\..\lib\net\2.0\log4net.dll + + + ..\..\..\..\..\lib\NHibernate32\net\4.0\NHibernate.dll + + + False + ..\..\..\..\..\bin\net\4.0\debug\Spring.Aop.dll + + + ..\..\..\..\..\bin\net\4.0\debug\Spring.ConversationWA.NH32.dll + + + False + ..\..\..\..\..\bin\net\4.0\debug\Spring.Core.dll + + + False + ..\..\..\..\..\bin\net\4.0\debug\Spring.Data.dll + + + False + ..\..\..\..\..\bin\net\4.0\debug\Spring.Data.NHibernate32.dll + + + False + ..\..\..\..\..\bin\net\4.0\debug\Spring.Web.dll + + + + + + False + ..\..\lib\net\2.0\System.Data.SQLite.DLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ASPXCodeBehind + + + CustomerEditor.aspx + + + CustomerList.aspx + + + CustomerOrders.aspx + + + CustomerView.aspx + + + Default.aspx + + + FulfillmentResult.aspx + + + + + CustomerEditor.aspx + ASPXCodeBehind + + + CustomerList.aspx + ASPXCodeBehind + + + CustomerOrders.aspx + ASPXCodeBehind + + + CustomerView.aspx + ASPXCodeBehind + + + Default.aspx + ASPXCodeBehind + + + FulfillmentResult.aspx + ASPXCodeBehind + + + MasterPage.master + ASPXCodeBehind + + + MasterPage.master + + + + + + + + + + + {6E4F55A0-C281-4706-A08B-BDEC2D2FBDA4} + Spring.Northwind.Dao.NHibernate.2010 + + + {7F45EEA2-50AC-44E2-85A6-2FFB02E38C44} + Spring.Northwind.Dao.2010 + + + {9E15876F-E9E0-43B7-9874-B54F163757D6} + Spring.Northwind.Service.2010 + + + + + + + + + + + + + + + + + + False + True + 60934 + / + + + False + False + + + False + + + + + + copy "$(ProjectDir)Web.net40.config" "$(ProjectDir)Web.config" /Y + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.config b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.config new file mode 100644 index 00000000..3b9cfa3f --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.config @@ -0,0 +1,73 @@ + + + + + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net30.config b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net30.config new file mode 100644 index 00000000..875cea62 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net30.config @@ -0,0 +1,74 @@ + + + + + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net40.config b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net40.config new file mode 100644 index 00000000..3b9cfa3f --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.net40.config @@ -0,0 +1,73 @@ + + + + + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.xml b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.xml new file mode 100644 index 00000000..250282e9 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/Web.xml @@ -0,0 +1,135 @@ + + + + + + + The Northwind web layer definitions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + conversationManager + + + + + + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/port_conversation.txt b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/port_conversation.txt new file mode 100644 index 00000000..7e0c3a12 --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/port_conversation.txt @@ -0,0 +1,196 @@ + I prepared the sample application and posted in +https://jira.springsource.org/browse/SPRNET-1431 as the file +"Spring.ConversationWA.example.zip.". + Below explanations to clarify (or not) what I did. + + This "sample application" is a modification of "Spring.Data.NHibernate.Northwind" +contained in the version "1.3.0" of "Spring.NET" to use Conversation. + Currently, the "Spring.Net" has no "conversation scope" or implements the +concept of "Extended Persistence Context" ("session per conversation strategy"). + +In this Sample Application the objective is demonstrate: +1) How to keep instances of objects in a mimicry of "conversation scope". + Shown in [expression="@(convCustomer)['CustomerEditController']"]. +2) How to enjoy the "extended persistence context". "Lazy load errors" do not happen + anymore and repeated calls of "ISession.Get" to a "same record" do not cause + numerous visits to the database, we take advantage of NHibernatecache. + The modifications on "CustomerList.aspx" demonstrate this. + To verify the effectiveness of Conversation, comment on + "App_Code\ConversationPage.cs" the line + "this.Conversation.StartResumeConversation ();" then you will see the error + "failed to lazily initialize a collection of role" occurring at the click + of the button "+" on "CustomerList.aspx". + + +IMPORTANT: Never use a single conversation for the entire application (with the + same duration of the "HTTP Session"). Remember, NHibernate keeps a cache of all + loaded objects, if the conversation is held for a long time this cache tends to + grow indefinitely (the limit is the amount of database records). That is, each + conversation should be limited to a subset of the application pages, and must + be discarded at the end of interaction with this subset + (IConversationState.EndConversation()). + In "Spring.ConversationWA.Imple.WebConversationManager" keep + [] is recommended, so when you start + a conversation the others are discarded. + +ADDITIONAL INFORMATION: The unit tests ("Spring.Northwind.IntegrationTests.2008") + are not working. But there is no problem because it is not related to the + changes made to support conversation, in fact they were already resulting in + errors even before that. + + +List of changes in "Spring.Data.NHibernate.Northwind": + + -Spring.Northwind.Web.References.2008 + Adding links to schemes to enable auto complete. + -web.config + -module, added: + + + -module, removed: + + + -web.xml + -module configurations + + + + + + + + + + + conversationManager + + + + + + + + + -conversation manager + + + + + + -Customer Conversation + + + + + + + + + + + + + -Change "CustomerEditController" scope, remove [scope="session"] and put [singleton="false"]: + + + + ... + + -Change reference for 'CustomerEditController' remove [ref="CustomerEditController"] and put [expression="@(convCustomer)['CustomerEditController']"] + + + + + + ... + + + + + + + + + + + + + ... + + + + + + + + + + + + ... + + + + + + + + + ... + + + + + + + + + + + -Added "ConversationPage.cs" + -Base page with support for conversation. + -CustomerList.aspx + -Allow list the "Order's" on the same page without lazy initialization error + occurs. All objects stay attached to ISession (NHibernate). + -CustomerList.aspx.cs: + -Added property "IList CustomersDetachedList". List not attached. + Searching the database only once per conversation. + -Changing the "Page_InitializeControls" for consider "CustomersDetachedList". + -Change "Page_InitializeControls" to "Page_Init". + -The method "BtnShowOrders_Click" performe a implicitly a "lazy load" on + "Customer.Orders". + -Change [CustomerEditor : Spring.Web.UI.Page] to [CustomerEditor : Spring.Web.UI.Page] on: + -CustomerEditor.aspx.cs + -CustomerList.aspx.cs + -CustomerOrders.aspx.cs + -CustomerView.aspx.cs + -FullfillmentResult.aspx.cs + -Default.aspx.cs + -Dao.xml + - Added [] to avoid + disconnection and reconnection before and after each IDbCommand execution. + This is important because we will do more lazyload outside the transaction + boundaries. + - Added: + ... + + + ... + -Default.aspx.cs + -Remove (they are never used): + -customerDao; + -fulfillmentService; + -CustomerDao; + -Button1_Click(object sender, EventArgs e); + -ProcessCustomer(); + -Config\Log4Net.xml. + ... + + + + + ... + + + + diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.htm b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.htm new file mode 100644 index 00000000..bb9c286d --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.htm @@ -0,0 +1,1255 @@ + + + + + + + .net - Nhibernate session per conversation example - Stack Overflow + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ + + + + +
+ + + + +
+ + +
+ + +
+ +
+
+ + + + + + + + + + + +
+ + + + + +
+
+

Hello can some pros with nhibernate give me example +implementation of Nhibernate session per conversation or unhaddins +implementation? +Or explain how to do that. +Best regards +Endiss

+ +
+ + + + + + + +
+
link|improve this question
+
+ + +
+ +
+
+
+
+ + + + + + + + + + +
Added tags to increase visibility – EtherDragon 20 hours ago
+
+ + +
+ feedback +
+ +
+
+ + + +
+ + +
+
+

1 Answer

+
+ active +oldest +votes + +
+
+
+ + + + +
+ + + + + + + + + + + +
+ + +
+ + up vote + 1 + down vote +accepted +
+ +
+

I work with NHibernate to 4 years. Previously I worked with the "open-session-per-operation" antipattern. + The objects were always detached. So, to persist, I had to reattach +them or copy their values to attached objects. This causes many lines of + code and many "lazy initialization exeption".

+ +

Recently, I studied the "Conversation pattern" and I did an implementation over the the "Spring.Net" infrastructure. The implementation was submitted to "jira.springsource" at the Issue SPRNET-1431 (Workaround for 'conversation scope' and "session-per-conversation").

+ +

I made no "sample application", but if you're interested I can do that.

+ +

Hailton

+ +

Supplementary Answer:

+ +

I prepared the sample application and posted in SPRNET-1431 Workaround for 'conversation scope' and "session-per-conversation" as the file "Spring.ConversationWA.example.7z".

+ +

Below, I wrote explanations to clarify (or not) what I did.

+ +

This "sample application" is a modification of +"Spring.Data.NHibernate.Northwind" contained in the version "1.3.0" of +"Spring.NET" to use Conversation. + Currently, the "Spring.Net" has no "conversation scope" nor implements + the concept of "Extended Persistence Context" ("session per +conversation strategy").

+ +

In this Sample Application the objective is demonstrate:

+ +
    +
  1. How to keep instances of objects in a mimicry of "conversation scope". Shown in expression="@(convCustomer)['CustomerEditController']".
  2. +
  3. How to enjoy the "extended persistence context". "Lazy load errors" do not happen anymore and repeated calls to ISession.Get + to a "same record" do not cause numerous visits to the database, more +efficient use of the NHibernate cache. The modifications on +"CustomerList.aspx" demonstrate this. To verify the effectiveness of +Conversation, comment on "App_Code\ConversationPage.cs" the line this.Conversation.StartResumeConversation(); + then you will see the error "failed to lazily initialize a collection +of role" occurring at the click of the button "+" on +"CustomerList.aspx".
  4. +
+ +

IMPORTANT: Never use a single conversation for the entire application + (with the same duration of the "HTTP Session"). Remember, NHibernate +keeps a cache of all loaded objects, if the conversation is held for a +long time this cache tends to grow indefinitely (the limit is the amount + of database records). That is, each conversation should be limited to a + subset of the application pages, and must be discarded at the end of +interaction with this subset (IConversationState.EndConversation()). Recommendation: Keep <property name="EndPaused" value="true"/> in "Spring.ConversationWA.Imple.WebConversationManager", so when start a conversation the others are discarded.

+ +

ADDITIONAL INFORMATION: The unit tests +("Spring.Northwind.IntegrationTests.2008") are not working. But there is + no problem because it is not related to the changes made to support +conversation, in fact they were already resulting in errors even before +that.

+ +

List of changes in "Spring.Data.NHibernate.Northwind":

+ +
    +
  • Spring.Northwind.Web.References.2008 +
      +
    • Adding links to schems to enable auto complete.
    • +
  • +
  • web.config

    + +
      +
    • module, added: +

      + +
      <add 
       
      name="ConversationModule"
       
      type="Spring.ConversationWA.HttpModule.ConversationModule, Spring.ConversationWA"/>  
      <add
       
      name="ConversationModule"
       
      type="Spring.ConversationWA.HttpModule.ConversationModule, Spring.ConversationWA"/>
    • +
    • module, removed: +

      + +
      <add 
       
      name="OpenSessionInView"
       
      type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate21"/>
    • +
  • +
  • web.xml

    + +
      +
    • module configurations +

      + +
      <!--Configuration for Spring HttpModule interceptor's-->
      <object
         
      name="HttpApplicationConfigurer"
         
      type="Spring.Context.Support.HttpApplicationConfigurer, Spring.Web">
       
      <property name="ModuleTemplates">
         
      <dictionary>
           
      <entry key="ConversationModule">
             
      <!-- this name must match the module name -->
             
      <object>
               
      <!--
                select "view source" in your browser on any page to
                see the appended html comment
                -->

               
      <property name="ConversationManagerNameList">
                 
      <list element-type="string">
                   
      <value>conversationManager</value>
                 
      </list>
               
      </property>
             
      </object>
           
      </entry>
         
      </dictionary>
       
      </property>
      </object>
    • +
    • conversation manager +

      + +
      <!--Conversation Manager-->
      <object
         
      name="conversationManager"
         
      type="Spring.ConversationWA.Imple.WebConversationManager, Spring.ConversationWA"
         
      scope="session">
       
      <property name="SessionFactory" ref="NHibernateSessionFactory"/>
       
      <property name="EndPaused" value="true"/>
      </object>
    • +
    • Customer Conversation +

      + +
      <!--
       Conversation for 'CustomerEditor.aspx', 'CustomerList.aspx',
       'CustomerOrders.aspx', 'CustomerView.aspx',  and 'FulfillmentResult.aspx'
      -->

      <!--
       Important: If the application had other parties
       ("management employees" for example), they should use another
       conversation.
      -->

      <object
         
      name="convCustomer"
         
      type="Spring.ConversationWA.Imple.WebConversationSpringState, Spring.ConversationWA"
         
      scope="session">
       
      <property name="Id" value="convCustomer"></property>
       
      <property name="TimeOut" value="0"></property>
       
      <property name="ConversationManager" ref="conversationManager"></property>
       
      <property name="SessionFactory" ref="NHibernateSessionFactory"/>
       
      <property name="DbProvider" ref="DbProvider"/>
       
      <!--
          Using workaround for 'conversation scope' to reference for
          'CustomerEditController'. It is not as volatile as "request scope"
          not as durable as the "session scope"
        -->

       
      <property name="['CustomerEditController']" ref="CustomerEditController"></property>
      </object>
    • +
    • Change "CustomerEditController" scope, remove [scope="session"] and put [singleton="false"]: +

      + +
      <object 
         
      name="CustomerEditController"
         
      type="NHibernateCustomerEditController"
         
      singleton="false">
       
      <constructor-arg name="sessionFactory" ref="NHibernateSessionFactory"/>
      </object>
      ...
    • +
    • Change reference for "CustomerEditController", remove ref="CustomerEditController" and put expression="@(convCustomer)['CustomerEditController']" (Simulating "conversation scope"): +

      + +
      <!--
        Using workaround for 'conversation scope' to reference for
        'CustomerEditController'. It is not as volatile as "request scope"
        not as durable as the "session scope"
      -->

      <object name="CustomerEditPage" abstract="true">
       
      <property
         
      name="CustomerEditController"
         
      expression="@(convCustomer)['CustomerEditController']"/>
       
      <property name="Conversation" ref="convCustomer"/>
      </object>
    • +
  • +
+ +
        <!--
          Using workaround for 'conversation scope' to reference for
          'CustomerEditController'. It is not as volatile as "request scope"
          not as durable as the "session scope"
        -->

       
<object type="CustomerView.aspx">
         
<property name="CustomerDao" ref="CustomerDao" />
         
<property
           
name="CustomerEditController"
           
expression="@(convCustomer)['CustomerEditController']" />
         
<property name="Conversation" ref="convCustomer"/>
         
<property name="Results">
           
<dictionary>
             
<entry key="EditCustomer" value="redirect:CustomerEditor.aspx" />
             
<entry key="CustomerList" value="redirect:CustomerList.aspx" />
           
</dictionary>
         
</property>
       
</object>
+ +
        <!--
          Using workaround for 'conversation scope' to reference for
          'CustomerEditController'. It is not as volatile as "request scope"
          not as durable as the "session scope"
        -->

       
<object type="FulfillmentResult.aspx">
         
<property name="FulfillmentService" ref="FulfillmentService" />
         
<property
           
name="CustomerEditController"
           
expression="@(convCustomer)['CustomerEditController']" />
         
<property name="Conversation" ref="convCustomer"/>
         
<property name="Results">
           
<dictionary>
             
<entry key="Back" value="redirect:CustomerOrders.aspx" />
           
</dictionary>
         
</property>
       
</object>
+ +
        <object type="Default.aspx">
         
<property name="Conversation" ref="convDefault"/>
         
<property name="Results">
           
<dictionary>
             
<entry key="CustomerList" value="redirect:CustomerList.aspx" />
           
</dictionary>
         
</property>
       
</object>
+ +
        <!--Conversation for 'Default.aspx'-->
       
<!--
          "convDefault" will have only one functionality: trigger the release
          of other conversations when started (StartResumeConversation())
        -->

       
<object
           
name="convDefault"
           
type="Spring.ConversationWA.Imple.WebConversationSpringState, Spring.ConversationWA"
           
scope="session">
         
<property name="Id" value="convDefault"></property>
         
<property name="TimeOut" value="0"></property>
         
<property name="ConversationManager" ref="conversationManager"></property>
         
<property name="SessionFactory" ref="NHibernateSessionFactory"/>
         
<property name="DbProvider" ref="DbProvider"/>
       
</object>
+ +
    +
  • Added "ConversationPage.cs". Base page with support for conversation.
  • +
  • CustomerList.aspx +
      +
    • Allow list the "Order's" on the same page without "lazy +initialization error". All objects stay attached to ISession +(NHibernate).
    • +
  • +
  • CustomerList.aspx.cs: +
      +
    • Added property IList<Customer> CustomersLoadedOncePerConvList. List loaded only once, searching the database only once per conversation.
    • +
    • Changing the Page_InitializeControls for consider CustomersLoadedOncePerConvList.
    • +
    • The method BtnShowOrders_Click performe implicitly a "lazy load" on Customer.Orders.
    • +
  • +
  • Change ??? : Spring.Web.UI.Page to ??? : Spring.Web.UI.Page on: +
      +
    • CustomerEditor.aspx.cs
    • +
    • CustomerList.aspx.cs
    • +
    • CustomerOrders.aspx.cs
    • +
    • CustomerView.aspx.cs
    • +
    • FullfillmentResult.aspx.cs
    • +
    • Default.aspx.cs
    • +
  • +
  • Dao.xml

    + +
      +
    • Added <entry key="connection.release_mode" value="on_close"/> + to avoid disconnection and reconnection before and after each +IDbCommand execution. This is important because we will do more lazyload + outside the transaction boundaries.
    • +
    • Added: +

      + +
      ...
      <entry key="show_sql" value="true"/>
      <entry key="format_sql" value="true"/>
      ...
    • +
  • +
  • Remove from "Default.aspx.cs" (they are never used):

    + +
      +
    • customerDao;
    • +
    • fulfillmentService;
    • +
    • CustomerDao;
    • +
    • Button1_Click(object sender, EventArgs e);
    • +
    • ProcessCustomer();
    • +
  • +
  • Config\Log4Net.xml. +

    + +
    ...
    <!--detail's about SQL's. To view sql commands on Logs\log.txt-->
    <logger name="NHibernate.SQL">
     
    <level value="DEBUG" />
    </logger>
    ...
    <!--detail's about Conversation-->
    <logger name="Spring.ConversationWA">
      <level value="DEBUG" /
    >
    </logger>
  • +
+ +

Hailton de Castro.

+
+ + + + + + + + +
+
link|improve this answer
+ + + + +
+
+
+ + + + + + + + + + +
Can you make some sample it will help me a lot :) – Endiss yesterday
+
+ + +
Was this post useful to you?     
+ +
+
+ + + + + + + +
+
+ + + + +
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.pdf b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.pdf new file mode 100644 index 00000000..9899e331 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app.pdf differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/4c4f1be011a447efbce49c1811022e7a.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/4c4f1be011a447efbce49c1811022e7a.png new file mode 100644 index 00000000..7d8b581a Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/4c4f1be011a447efbce49c1811022e7a.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/6ee355d0469e16a5fc5bb0dc9c949a75.png b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/6ee355d0469e16a5fc5bb0dc9c949a75.png new file mode 100644 index 00000000..2d1d55e6 Binary files /dev/null and b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/6ee355d0469e16a5fc5bb0dc9c949a75.png differ diff --git a/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/adzerk1_2_4_43adzerk2_2_17_45.js b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/adzerk1_2_4_43adzerk2_2_17_45.js new file mode 100644 index 00000000..ba3cc4de --- /dev/null +++ b/examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.ConvWA/readme/sof_aboult_samble_app_arquivos/adzerk1_2_4_43adzerk2_2_17_45.js @@ -0,0 +1 @@ + function cssLoad(css){var s=document.createElement('style');document.getElementsByTagName('head')[0].appendChild(s);if(!!window.ActiveXObject){document.styleSheets[document.styleSheets.length-1].cssText=css;}else{stylenode=document.createTextNode(css);s.appendChild(stylenode);}}function azHtmlLoad(div,content){var azDiv=document.getElementById(div);azDiv.innerHTML=content;}function azScriptSRCLoad(div,script){var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=script;var azDiv=document.getElementById(div);azDiv.appendChild(newScript);}function azScriptInlineLoad(div,script,interval){var newScript=document.createElement('script');newScript.type='text/javascript';if(/msie/.test(navigator.userAgent.toLowerCase())){newScript.text=script;}else{newScript.innerHTML=script;}var azDiv=document.getElementById(div);azDiv.appendChild(newScript);}function azLoad(div,code){var azDiv=document.getElementById(div);if(azDiv){code();}else {setTimeout(function(){azLoad(div,code)},100);}}var zItems=[];function zshow(div){if(zItems[div]){document.write(zItems[div]);}}function ados_frameLoaded(x, y) {};function ados_loadFIframe(a,b,c,d,e){adzerkDiv=document.getElementById(a);ifrm=document.createElement("iframe");ifrm.frameBorder=0;ifrm.scrolling="no";ifrm.noresize="noresize";ifrm.marginheight=0;ifrm.marginwidth=0;if(d!=0){ifrm.height=d}if(e!=0){ifrm.width=e}ifrm.onload=function(){ados_frameLoaded(a,c)};adzerkDiv.innerHtml="";adzerkDiv.appendChild(ifrm);ifrm.contentWindow.contents='