On 04/25/2010 04:37 PM, Arne Vajh?j wrote:
On 25-04-2010 01:03, Jack wrote:
When I work on database development projects, I use JDBC and SQL. Many
people use hibernate/spring. Can somebody explain the pros and cons of
using JDBC and SQL vs using hibernate/spring on database
developments?
That is a rather big discussion.
The ultra short version is:
- ORM (Hibernate or other) is best when the problem to
be solved is CRUD of objects
- pure SQL (JDBC) is best when you want to do something
more unusual
Notably manipulating large volumes of data. While there are some
features in JPA and likes working efficiently with large volumes of data
often requires exploiting features of the particular RDBMS at hand. That
soon becomes awkward if you want to do it through a ORM.
And one downside of using Hibernate, JPA or any other ORM tool: these
tools hide the often quoted impedance mismatch between the object world
and the database - which is good because that is precisely what they
were invented for. The danger here is to use a persistent store
mindlessly just like objects in memory which has a good chance of
leading to awful performance in certain situations. In a way you could
say the hiding works but not for every use case and sometimes you're
crossing from "works" to "major nuisance" without noticing it. Bottom
line, with Hibernate as well as with any other tool, you should know it
and its weaknesses (which to a certain extent makes the "hiding" moot).
alternatives) are in the writing of the code. It still requires
to write really efficient code.
The big benefits are for reading the code. Everyone can read the
looking at tons of code that uses JDBC and SQL. It is maintenance
friendly.