0

I am designing a system from scratch. I am contemplating :

  1. whether to use DAL at all vs direct DB access(ORM for example)
  2. If I use DAL, do I store/manage my User Sessions directly via my application or in the DAL?

the basic architecture is client -> application BackEnd -> DAL -> DB

Ohad Perry
  • 1,315
  • 2
  • 15
  • 26

1 Answers1

0

Your Data Access Layer can use an ORM tool (like Hibernate (Java), NHibernate (.Net)) to do the database access. No problem with this. You could abstract the funcionalities into a model layer and implement it on your DAL project, for sample:

public interface ICustomerPersistence
{
   Customer Get(int id);
   bool Save(Customer customer);
}

and implement it using an ORM or another way to access the database (ADO.NET or JDBC).

Using an ORM tool, you will have a internal layer between your application and database. On the other hand, an ORM tool can provide to you and your team some productivity persisting objects instead writing SQL queries. On both cases, the SQL must be clean to provide performance. With ORM tools, probably you will need a trace tool to see the SQL commands generated by the ORM. For NHibernate, there is a NHProf.

For the second question, depende how you must implement. Most implementations of ORM like Hibernate/NHibernate do the control of the ISession object from an up layer from the DAL. For sample, as a good pratice in web applications, the ISession is open in the begin request and closed into end request. Sometimes it is also done by the Transaction.

Felipe Oriani
  • 37,948
  • 19
  • 131
  • 194
  • Thanks @felipe, I have edited the first question for more clarity. – Ohad Perry Dec 26 '14 at 18:45
  • I add some more content. Anyway, I recommend you implement your DAL with an ORM tool, but, make sure you know what happens when you use the ORM. Remember to check if as anwser if it help you to find the solution. – Felipe Oriani Dec 26 '14 at 18:49