I was reading about Hibernate but have never used it for persistence. One think i found difficult to understand is why will anyone use Hibernate if they have a option of using a CMP Entity beans.
Any thoughts around this are welcome ?
because cmp is crap
Hibernate is smaller, lighter, and easier to use compared to the EJB mega-frameworks.
Hibernate is transparent, in that your model contains no persistence code of any kind. All you need is to provide a default, parameterless constructor.
Another advantage to hibernate is that it only deals with JDBC, allowing it to use a very SQL like query language.
For more information, a great book on Hibernate and other ejb alternatives is "Better, Faster, Lighter Java," by Bruce Tate and Justin Gehtland
Hibernate vs Toplink vs CMP : http://www.theserverside.com/discussions/thread.tss?thread_id=27037
Spring/Hibernate vs J2EE / EJB :
Your question should have read: "Why will anyone use CMP Entity Beans if they have the option of using Hibernate."
But seriously, here are a few reasons:
1- Hibernate is more powerful.
You can express many things with Hibernate that cannot be done with CMPs (At least without resorting to Server specific functions, which would make your app less portable). Things like ordering of results, placing limits/offset on the data you require (usefull for paging). Dynamic queries etc.
2- Hibernate uses POJOs.
This brings many benefits, such as the ability to run outside of a J2EE app server. (For example I can run junit tests on my DAO layer during my build cycle.
4- Easy of use
Let me tell you what I know is,If there is any wrong conception, Please tell me at uday_thakare1981 at yahoo dot comHibernate is more usefull than ejb b'coz it is simple, no need to create a structure There is less database connectivity code Easier to use when your database is varring that is for extensibity It uses cashing so less database transaction