views:

739

answers:

8

Hi folks,

this morning I was aboard a S-Bahn (German Subway) and I met a fellow student, who works for IBM. What he is doing there is JEE optimization. I told him about my little project. And he recommended not to use 'oldschool' hibernate. That's why my question is:

Is Hibernate deprecated? (In combination with JEE/Web Development)

..or did he just prate..

cheers

+1  A: 

JPA is only one way to do it. There's still Spring and all the other frameworks where Hibernate is well alive.

Konrad Garus
+17  A: 

No, Hibernate is not deprecated.

However, there's now JPA (Java Persistence API), which is a standard API for doing the things that Hibernate does.

Note that JPA is just an interface specification. You'll need something that implements JPA, and Hibernate is one of the implementations of JPA. Besides Hibernate, there are a few others such as EclipseLink (the official reference implementation for JPA) and Apache OpenJPA.

Jesper
In my opinion I'd still stick with Hibernate (using annotations, as it's my preference over XML for persistence) as it has a lot of things which JPA hasn't, yet, personally I'll wait for JPA 2.0.
Binary255
JPA also works with annotations, not necessarily with XML. JPA 2.0 has been out for a while, but not everything supports it yet. I'd choose JPA, unless there is some compelling reason to use plain Hibernate (for example features that you really need that are not available through JPA).
Jesper
@Binary255: JPA 2.0 **is** there and the gap between JPA 2.0 and Hibernate is thin now.
Pascal Thivent
Oh. I've been out of the loop, sorry. I've only used JPA 1.0 in the past and compared to Hibernate the latter won, even though the former was a standard. It's good if the standard has evolved though, I would use the standard too if I didn't find it lacking something vital to me.
Binary255
+3  A: 

Hibernate is the JPA provider offered by JBoss, which is a Java EE server, so I doubt that Hibernate as an implementation is deprecated.

Perhaps he meant that using Hibernate within a Java EE server , bypassing the container-provider persistence, is deprecated and you should rely on our container for such services.

Robert Munteanu
+2  A: 

No, there is no way that Hibernate is deprecated. There is the JPA which is a persistence specification and Hibernate implements it. Also Hibernate has its own advanced features that JPA does not have and that's why Hibernate is the main source of new features that are added to the JPA standard.

Petar Minchev
+2  A: 

One possible reason why he may have suggested you against Hibernate is that for a small project, the overhead of understanding Hibernate can be quite significant.

Hibernate is vast to say the least. Though it can be used in a simple way, but to find that out too, you'll need to comprehend a whole lot more.

but be rest assured that Hibernate is NOT deprecated, or going to be any time in the distant future. it's just that if your ORM needs are modest, you might want to try other solutions like iBATIS

anirvan
+4  A: 

Hibernate, apart from being an implementation of JPA, does provide a lot of extra advanced feature that JPA lacks of (extra syntax in query, QBC support etc). Some of them are really useful and hard to find a workaround in JPA world (yet). Without providing such features, it is hard to say JPA can "replace" Hibernate (hence, saying Hibernate being deprecating)

Adrian Shum
A *lot of extra advanced features* is not so true anymore with JPA 2.0. Yes, JPA 2.0 is still lacking some features such as Query By Example, custom user types,... but JPA 2.0 is a big improvement and makes the need for proprietary features rare.
Pascal Thivent
A: 

i think that he meant that using hibernate without fully understanding how it works creates a lot of performance problems(you can query every table with simple single query if you dont understand how collections work). I saw that in one application - every select was at least 1MB of data, because hibernate was misused.

Some people believe that using pure JDBC is better for performance than using hibernate(its not true, because hibernate cache can speed-up your application).

You should from time to time look what SQL queries it generates and in some cases use native SQL queries(for better performance). In some cases using datebase specific features wiill give you great performance. Many people believe that hibernate app should be database agnostic, so you can latter change database without any changes to the code. I have never seen that happened.

If you read the hibernate reference you should do ok.

01
I don't buy the caching arguments. At the end of the day your data has to come from the db, "cached" data becomes stale eventually. I use Hibernate but I think one of it's larger flaws is that it's too darn easy to misuse, unless you're an expert, and few people really are.
Crusader
A: 

Based on what you said, it sounds like he may have been referring to Hibernate xml mappings, in contrast to using Hibernate annotations or JPA. XML is most certainly old-school rubbish.

Crusader