-->
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.  [ 6 posts ] 
Author Message
 Post subject: Why using NHibernate ?
PostPosted: Wed May 23, 2007 4:16 am 
Newbie

Joined: Wed May 23, 2007 4:09 am
Posts: 16
I am not sure I understand why using nHibernate.
I understand well what it does but developping a class that can be serialized into a database isn't very hard to do. Simply add a method Serialize/UnSerialize with only a few lines of database code.
Using Enterprise Library (EntLib), I can write a code that is database independant.
The risk using nHibernate is to be dependant not with the dabase provider but with nHibernate itself.
I am afraid to waste more time learning nHibernate and finding fixes to tricky bugs than developping the few necessary lines of codes (about 20 lines) myself.
Is there a good article somewhere about the real advantages using nHibernate ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 8:38 am 
Newbie

Joined: Thu May 03, 2007 2:30 am
Posts: 18
Hello...

I think you slightly missunderstood what nHibernate does. The "Goal" of "nHibernate is to allow you a simple way to persist your objects"

nHibernate will not "just serialize" your object into a database. It will "neatly" take the object and save it into the appropiate database fields and tables. The "only" thing you need to do is to tell nhibernate into which fields this data will go.

Once you have set this up... you can work with your objects and retrieve and store them very simply from/to the database. Also there will be a whole slew of optimisations that you can use transperently (For example lazy loading of child collections, internal cache etc).

What the EntLib allows you to do is by far something different...

Using the EntLib you can "reduce" the lines of code needed to fetch data from a procedure into a recordset. But then the data is still not inside the object... You still need to maintain code to transfer the data from the Dataset into your object. (OK.. in NHibernate this is the mapping file, which tecnically is also code)

Also the code in the EntLib is not "really" DB independant... You still need to write sql that will be running on different DB Systems... And this is something that nhibernate will do for you...

For example... Get the "10 best paid employees" from the database... Which code would you write in sql that will run on all db systems? Each system will have a slightly different syntax for this. And nhibernate "understands" the different dialects, and will generate the (correct) querry for you... regardless of the DB system. Also it understands the available features of the target db.

On sql Server 2005 it will use "CTE" if the make sense and on oracle it will use "connect by"...

I hope this makes sense...

Also nHibernate allows you to build a database from your mapping...

So i hope this will do as a short feature description ;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 9:01 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Well, NHibernate will not use "CTE" or "connect by" by itself, let's not be over-enthusiastic :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 23, 2007 9:17 am 
Newbie

Joined: Thu May 03, 2007 2:30 am
Posts: 18
sergey wrote:
Well, NHibernate will not use "CTE" or "connect by" by itself, let's not be over-enthusiastic :)


Doh... ;)

I am sure i read that it does "somewhere"...

Anyway... "After the mappings are done", you should no longer care about the db access... and thats the "goal"


Top
 Profile  
 
 Post subject: Comparing to Opf3
PostPosted: Fri May 25, 2007 3:14 am 
Newbie

Joined: Wed May 23, 2007 4:09 am
Posts: 16
Thanks a lot for your help.

One more question. Opf3 is a clone to nhibernate which is more .NET oriented and I develop a .NET application. I don't care having to pay or not for the library. Did anyone compare nhibernate with Opf3?

Where should I expect the best features and performances?


Top
 Profile  
 
 Post subject: Re: Comparing to Opf3
PostPosted: Sat Jun 02, 2007 4:17 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 1:43 pm
Posts: 22
prince0 wrote:
One more question. Opf3 is a clone to nhibernate which is more .NET oriented and I develop a .NET application


Hmm... I believe everybody on this forum develops .NET applications :) Anyway, what part of NH is not enough .NET oriented?


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