What's the advantage of going for hibernate ?
Its a well written and maintained, pragmatic ORM layer. Much simpler than many others. Opensource, so free to use. It claims to be the quickest too (though I've never benchmarked it - so I'll just have to take their
word for it). And the next EJB spec looks like it will borrow heavily from their design.
When should we use it ?
Any time you need an ORM layer.
How does it compare with EJB ?
It doesn't. Hibernate is not a container managed service, it is an ORM layer. So it can be used in conjuction with EJB or not as you require. It can be compared to Entity BEans - but they are so poorly designed that they don't stand up to the comparison too well.