Skip to content

Commit 4c56756

Browse files
committed
Visual updates to Northwind demo, some refactoring
1 parent 573a090 commit 4c56756

File tree

29 files changed

+444
-333
lines changed

29 files changed

+444
-333
lines changed

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateCustomerDao.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public string Save(Customer customer)
6464
}
6565

6666
[Transaction(ReadOnly = false)]
67-
public void SaveOrUpdate(Customer customer)
67+
public void Update(Customer customer)
6868
{
6969
Session.SaveOrUpdate(customer);
7070
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateOrderDao.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,41 @@
2626
using Spring.Data.NHibernate.Support;
2727

2828
using Spring.Northwind.Domain;
29+
using Spring.Stereotype;
30+
using Spring.Transaction.Interceptor;
2931

3032
#endregion
3133

3234
namespace Spring.Northwind.Dao.NHibernate
3335
{
36+
[Repository]
3437
public class HibernateOrderDao : HibernateDao, IOrderDao
3538
{
39+
[Transaction(ReadOnly = true)]
3640
public Order Get(int orderId)
3741
{
3842
return Session.Get<Order>(orderId);
39-
4043
}
4144

45+
[Transaction(ReadOnly = true)]
4246
public IList<Order> GetAll()
4347
{
4448
return GetAll<Order>();
4549
}
4650

51+
[Transaction]
4752
public int Save(Order order)
4853
{
4954
return (int) Session.Save(order);
5055
}
5156

52-
public void SaveOrUpdate(Order order)
57+
[Transaction]
58+
public void Update(Order order)
5359
{
5460
Session.SaveOrUpdate(order);
5561
}
5662

63+
[Transaction]
5764
public void Delete(Order order)
5865
{
5966
Session.Delete(order);

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Dao/NHibernate/HibernateProductDao.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,41 @@
2525
using Spring.Data.NHibernate.Support;
2626

2727
using Spring.Northwind.Domain;
28+
using Spring.Stereotype;
29+
using Spring.Transaction.Interceptor;
2830

2931
#endregion
3032

3133
namespace Spring.Northwind.Dao.NHibernate
3234
{
35+
[Repository]
3336
public class HibernateProductDao : HibernateDao, IProductDao
3437
{
38+
[Transaction(ReadOnly = true)]
3539
public Product Get(int productId)
3640
{
3741
return Session.Get<Product>(productId);
38-
3942
}
4043

44+
[Transaction(ReadOnly = true)]
4145
public IList<Product> GetAll()
4246
{
4347
return GetAll<Product>();
4448
}
4549

50+
[Transaction]
4651
public int Save(Product product)
4752
{
4853
return (int) Session.Save(product);
4954
}
5055

51-
public void SaveOrUpdate(Product product)
56+
[Transaction]
57+
public void Update(Product product)
5258
{
5359
Session.SaveOrUpdate(product);
5460
}
5561

62+
[Transaction]
5663
public void Delete(Product product)
5764
{
5865
Session.Delete(product);

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao.NHibernate/Spring.Northwind.Dao.NHibernate.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
<SpecificVersion>False</SpecificVersion>
3737
<HintPath>..\..\..\..\..\bin\net\2.0\debug\Common.Logging.dll</HintPath>
3838
</Reference>
39+
<Reference Include="FluentNHibernate, Version=0.1.0.535, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
40+
<SpecificVersion>False</SpecificVersion>
41+
<HintPath>..\..\lib\net\2.0\FluentNHibernate.dll</HintPath>
42+
</Reference>
3943
<Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
4044
<SpecificVersion>False</SpecificVersion>
4145
<HintPath>..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll</HintPath>
@@ -61,6 +65,7 @@
6165
<HintPath>..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate21.dll</HintPath>
6266
</Reference>
6367
<Reference Include="System" />
68+
<Reference Include="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
6469
<Reference Include="System.Data" />
6570
<Reference Include="System.Xml" />
6671
</ItemGroup>

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ICustomerDao.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
namespace Spring.Northwind.Dao
3030
{
31+
/// <summary>
32+
/// Customer related DAO operations interface.
33+
/// </summary>
3134
public interface ICustomerDao : IDao<Customer, string>, ISupportsDeleteDao<Customer>, ISupportsSave<Customer, string>
3235
{
3336
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IDao.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
namespace Spring.Northwind.Dao
44
{
5+
/// <summary>
6+
/// Generic DAO interface with minimum retrieval methods.
7+
/// </summary>
8+
/// <typeparam name="TEntity">Entity to operate with.</typeparam>
9+
/// <typeparam name="TId">Entity id type.</typeparam>
510
public interface IDao<TEntity, TId>
611
{
712
/// <summary>

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IOrderDao.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
namespace Spring.Northwind.Dao
3030
{
31-
public interface IOrderDao : IDao<Order, int>, ISupportsDeleteDao<Order>
31+
/// <summary>
32+
/// Order related DAO operations interface.
33+
/// </summary>
34+
public interface IOrderDao : IDao<Order, int>, ISupportsDeleteDao<Order>, ISupportsSave<Order, int>
3235
{
33-
int Save(Order order);
34-
35-
void SaveOrUpdate(Order order);
3636
}
3737
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/IProductDao.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
namespace Spring.Northwind.Dao
3030
{
31+
/// <summary>
32+
/// Product related DAO operations interface.
33+
/// </summary>
3134
public interface IProductDao : IDao<Product, int>, ISupportsDeleteDao<Product>, ISupportsSave<Product, int>
3235
{
3336

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
namespace Spring.Northwind.Dao
22
{
3+
/// <summary>
4+
/// Role interface for DAOs that support deletion of entities.
5+
/// </summary>
6+
/// <typeparam name="TEntity">Entity type.</typeparam>
37
public interface ISupportsDeleteDao<TEntity>
48
{
9+
/// <summary>
10+
/// Deletes the entity.
11+
/// </summary>
12+
/// <param name="entity">Entity to delete.</param>
513
void Delete(TEntity entity);
614
}
715
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Dao/Dao/ISupportsSave.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
namespace Spring.Northwind.Dao
22
{
3+
/// <summary>
4+
/// Role interface for DAOs that support saves and updates to entities.
5+
/// </summary>
6+
/// <typeparam name="TEntity">Entity type.</typeparam>
7+
/// <typeparam name="TId">Entity id type.</typeparam>
38
public interface ISupportsSave<TEntity, TId>
49
{
510
/// <summary>
@@ -13,6 +18,6 @@ public interface ISupportsSave<TEntity, TId>
1318
/// Saves or updates the entity. Behavior depends on the current state of entity's ID.
1419
/// </summary>
1520
/// <param name="entity">Entity to save or update.</param>
16-
void SaveOrUpdate(TEntity entity);
21+
void Update(TEntity entity);
1722
}
1823
}

examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Service/Service/FulfillmentService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void ProcessCustomer(string customerId)
9696
order.ShippedDate = DateTime.Now;
9797

9898
//Update shipment date
99-
OrderDao.SaveOrUpdate(order);
99+
OrderDao.Update(order);
100100

101101
//Other operations...Decrease product quantity... etc
102102
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<asp:DataGrid runat="server" CssClass="datagrid">
2+
<HeaderStyle CssClass="datagrid-header" />
3+
<ItemStyle CssClass="datagrid-item" />
4+
<AlternatingItemStyle CssClass="datagrid-alt-item" />
5+
<FooterStyle CssClass="datagrid-header" />
6+
</asp:DataGrid>

0 commit comments

Comments
 (0)