-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Service Layer Best Practices
PostPosted: Sat Sep 03, 2005 1:24 am 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Hi,

I'm new to NHibernate but have used ORM in a previous ASP.NET project with the following architecture:

Domain (OR mapped using non-POCO NPersist)
Service Layer
UI

The service layer was built using static methods that accepted primitive types only along with a reference to the persistence framework context. For example:

public static Customer CustomerServices.GetByID(Context context, int id)

public static int CustomerServices.Add(Context context, string name, DateTime dateOfBirth)

The persistence framework context was initialised in OnInit and disposed of in OnUnload and this was contained in a base page within the UI.

The service layer methods would begin, commit and rollback transactions as required by calling appropriate methods on the NPersist context.

Is this a good standard to apply to NHib as well, simply replacing the NPersist context with an NHib session or is it better for the UI to be completely unaware of the session? How about just passing primitive types into the service layer as opposed to domain objects...is this good practice? For example an alternative Add for a customer might be:

public static void CustomerServices.Add(Customer customer)

This would mean that the customer object is created in the UI and then just passed in to the service layer.

Any guidance is greatly appreciated.

Thanks,

Jason


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 03, 2005 9:31 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Have you read NHibernate Sessions in ASP.NET and ASP.NET and NHibernate session (and all other topics in the ASP.NET section) ?

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 03, 2005 7:27 pm 
Senior
Senior

Joined: Sat Sep 03, 2005 12:54 am
Posts: 139
Yes, I have seen the articles that you mention and have trawled through most of the online docs but haven't found anything that answers my specific questions about the service layer. Do you have any sample code that you would be able to share?

Thanks,

Jason


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.