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.  [ 7 posts ] 
Author Message
 Post subject: Beginner question
PostPosted: Fri Jul 07, 2006 12:28 pm 
Beginner
Beginner

Joined: Fri Jul 07, 2006 12:08 pm
Posts: 37
Hi,

I am developing a web app,in asp.net 2.0 using C#.I am following DDD,by eric evans,so i am building my domain first.Now,for persistance i wana use NHibernate..will it require me to code my classes in a certain way like needing to have getter/setter for propeprties etc..or any class can be persisted..is there any best practice i can follow?
thks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 4:56 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Some compromises will have to be made and some rules obeyed - collections have to be used through interfaces (IList, not List<T> or ArrayList) for example, but your objects will not have to depend on NHibernate for any functionality.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 11:12 pm 
Beginner
Beginner

Joined: Fri Jul 07, 2006 12:08 pm
Posts: 37
What I really want to know,do I have to use DAO type pattern for my domain objects,and this DAO will be used by nhibernate?
Say,i have a class which is immutable,how will nhiberrnate save this object,as it will not have any getter/setter,object is constructed fully only through constructor..
thks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 4:56 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Your objects have to have a no-argument constructor which may be private. NHibernate can also access private fields (through reflection) to set their values.

The DAO question is sort of orthogonal - use DAO if you want to, don't use it if you don't want to - DAO is a layer above NHibernate, so NHibernate doesn't care.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 6:36 am 
Beginner
Beginner

Joined: Fri Jul 07, 2006 12:08 pm
Posts: 37
thks sergey..how do i do the mapping for the private fields in the xml file?
using property tag?
Also,reading doc on persistent classes,says..
Declare accessors and mutators for persistent fields..is it mandatory?..just a bit confused..


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 6:40 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Declare them using <property ... access="field" /> or access="nosetter.camelcase" or substitute camelcase by whatever other naming strategy you use for the fields.

It's not mandatory to have getters and setters (accessors/mutators) declared, it's just easier to explain and performs slightly better.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 08, 2006 10:03 am 
Beginner
Beginner

Joined: Fri Jul 07, 2006 12:08 pm
Posts: 37
thks a bunch..


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