wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Can we use both EJB and Hibernate in the same project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Can we use both EJB and Hibernate in the same project" Watch "Can we use both EJB and Hibernate in the same project" New topic
Author

Can we use both EJB and Hibernate in the same project

Papa Rao Ushala
Greenhorn

Joined: May 12, 2008
Posts: 2
If we can use both EJB and Hibernate in the same project? What would be the role of EJB and Hibernate.
How the transactions will be handled , and how the business flow will be?

If the transactions are handled by EJB, then what is the HIbernate role?
If the transactions are handled by Hibernate, then what is the EJB role?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

Welcome to JavaRanch!

Yes. First, keep in mind that EJBs can be session beans, entity beans (in EJB 2) or message driven beans. Only entity beans serve the same purpose as hibernate. Using the other two types of EJB doesn't introduce two technologies with the same purpose.

In EJB 3, entity beans became an API called JPA. Hibernate is also an implementation of JPA. As you can see, these technologies are designed to work well together.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Paul Michael
Ranch Hand

Joined: Jul 02, 2001
Posts: 697
Hi,

I'm wondering which version of EJB you are referring to. You will be surprised how Hibernate plays a very important role in the EJB 3 world.

Prior to EJB 3, there exist Entity Beans which I don't think integrates nicely with Hibernate.

But then EJB 3 came, along with the new JPA specification (Java Persistence API), whose concepts were mostly derived from Hibernate (courtesy of Gavin King).

In fact, Hibernate is an implementation of JPA (TopLink is another famous implementation). So if you use JPA, I don't think transactions can be handled solely by either EJB or by Hibernate since they are now on the SAME team.

I think the more specific question would now be whether you want JTA transactions or resource local transactions.


SCJP 1.2 (89%), SCWCD 1.3 (94%), IBM 486 (90%), SCJA Beta (96%), SCEA (91% / 77%), SCEA 5 P1 (77%), SCBCD 5 (85%)
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Prior to EJB 3, there exist Entity Beans which I don't think integrates nicely with Hibernate.

Of course, you probably wouldn't use Entity Beans anyway because of their many well documented failings. Using Hiberate and session beans is a fine mix.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we use both EJB and Hibernate in the same project
 
Similar Threads
EJB usage in a web system
new to hibernate
Please comment on the application design
Hibernate in a multi-server architecture
What is EJB ?