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.  [ 5 posts ] 
Author Message
 Post subject: Design : NHibernate coupled with UI layer ?
PostPosted: Thu Oct 02, 2008 2:06 am 
Newbie

Joined: Thu Oct 02, 2008 2:04 am
Posts: 2
Dear NHibernate experts.

I have a design problem here, which is not really linked to NH but
more to the way C# works.

I work on a classical 3 layer application, Data layer (with NH),
Business layer, and UI Layer.

I don't want to couple the UI layer to the Data layer but I have the
following situation that enforces me to add a reference to the
NHibernate dll in the UI project.

I have nh mapped class that travel from the data layer to the ui
layer, and vice versa. So all 3 layer need to reference the project
containing those objects in order to manipulate them.

Here is the problem. One of my mapped nhibernate domain object class
implements ILifecycle in order to hook up life cycle events. Let's
call this class myDomainObject.
Because the UI displays that object, C# requires that the UI project
"knows about" the ILifecycle interface, that is to say, I must add a
reference to NH in the UI project.

Indeed C# does not support private inheritance as C++.

Question. Is that ok ? Is the design poor ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 7:24 am 
Newbie

Joined: Wed Oct 01, 2008 10:36 am
Posts: 3
http://markmail.org/message/erdsk7xjclc ... te:results


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 8:46 am 
Newbie

Joined: Fri Sep 28, 2007 4:12 am
Posts: 15
Alternatively, if you cannot find a way around the ILifecycle interface maybe you can define an Interface that just describes the properties and methods from that particular domain object needed by your UI layer and completely code your UI layer against that interface.

It is a very awkward thing to do for domain objects and I really don't recommend going this route though. You will not be able to create new instances of that domain object in the UI for example. Sure, a factory in the lower layer can expose this for you but you might end up having more and more complexity along the way.


Top
 Profile  
 
 Post subject: Re: Design : NHibernate coupled with UI layer ?
PostPosted: Sat Oct 11, 2008 6:10 am 
Regular
Regular

Joined: Mon Aug 29, 2005 3:07 pm
Posts: 77
fox_psvjlp@trashmail.net wrote:
Dear NHibernate experts.

I have a design problem here, which is not really linked to NH but
more to the way C# works.

I work on a classical 3 layer application, Data layer (with NH),
Business layer, and UI Layer.

I don't want to couple the UI layer to the Data layer but I have the
following situation that enforces me to add a reference to the
NHibernate dll in the UI project.

I have nh mapped class that travel from the data layer to the ui
layer, and vice versa. So all 3 layer need to reference the project
containing those objects in order to manipulate them.

Here is the problem. One of my mapped nhibernate domain object class
implements ILifecycle in order to hook up life cycle events. Let's
call this class myDomainObject.
Because the UI displays that object, C# requires that the UI project
"knows about" the ILifecycle interface, that is to say, I must add a
reference to NH in the UI project.

Indeed C# does not support private inheritance as C++.

Question. Is that ok ? Is the design poor ?

Thanks.

I want to respond with a question. :)

If you do not have a reference to the NHibernate dll in your UI, which part of your application is responsible for opening and closing connections (sessions) and for starting / committing / rollbacking transactions ?
In other words: which part of your application does know the context of when a new connection needs to be opened, or when a transaction needs to be started (or committed) ?


Top
 Profile  
 
 Post subject: IHttpModule
PostPosted: Sun Oct 12, 2008 7:35 pm 
Newbie

Joined: Thu Oct 02, 2008 2:04 am
Posts: 2
We use an asp.net IHttpModule to implement the Open-Session-In-View pattern. Pattern is described here : http://sourceforge.net/forum/message.php?msg_id=2847509


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.