This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
This could be a newbie question on ORM but bear with it.I want to know the additional benefits that of using ORM(tools) over JDBC.Some of things I found out are 1)we can use normal save,load and Hibernate(eg.) converts them automatically using SQL queries. 2)It provides support to store associations between classes. 3)Makes overall handling of the databases easier & improves performance.
I should point out that there's generally too much attention paid to the choice of Java persistence technology (e.g. Hibernate versus JDO) and not enough on the overall architectural strategy.
While using an ORM technology has benefits, you should also always consider using Data Access Objects - which will provide you with a level of independence from the technology choice (i.e. you can swap between ORM or JDBC or whatever as appropriate). This might be useful:
"Makes overall handling of the databases easier & improves performance."
I wouldn't necessarily say that it improves performance, and some out there can argue that it doesn't make handling databases easier.
What I think the main thing is that it removes Database specific information from your code, like SQL text. But in some cases you still want to use SQL through an ORM so that it is faster there, and the query is a simple query for like say a lookup.
I personally like the ability to use OO and Objects when dealing with things that represents tables in a database. I don't like dealing with JDBC directly, and ResultSets and Statements, etc. But others are fine with it.
JDBC Vs ORM [ in particular Hibernate ] ---------------------------------------
1. Query by example [ Criterial queries ] 2. Substituting the whole object as parameter to the query 3. Ease of persisting dependency 4. Automapping of result set to objects 5. Pagination 6. Polymorphic queries 7. Implicit joins .. Eg bid.item.category 8. Detached persistence
Note :- JDBC is good at read-only data. So if you are planning to you projections in Hibernate, you should give a shot to JDBC first, definitely faster than projections.