File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes EJB 3.0 + EntityManager or Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "EJB 3.0 + EntityManager or Spring" Watch "EJB 3.0 + EntityManager or Spring" New topic
Author

EJB 3.0 + EntityManager or Spring

Vinod Kumar
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
Hi,

Just wondering the trend of JEE5 projects these days w.r.t to application framework. With the EntityManager interface , JEE5 itself is easily configurable for persistence.
Also the annotations has made life simple with EJB3.0. Is there a need to go for Hibernate+Spring IOC if JEE5 provides these capabilities.?


Thanks in advance.

Regards,
Vinod Kumar

Christian Gossart
Ranch Hand

Joined: Mar 13, 2008
Posts: 34
With the EntityManager interface , JEE5 itself is easily configurable for persistence

Yep. Persistence Unit and annotated POJOs are the equivalent to Hibernate config files and BOs, EntityManager takes the place of the Hibernate session. In fact, most of the classes in the javax.persistence package are annotations. But keep in mind that annotations are compiled, and config files are not. I would say that annotations are OK from the developer POV, but config files are better from the integration/test POV.

Is there a need to go for Hibernate+Spring IOC if JEE5 provides these capabilities.?

As usual, it depends on your needs...
Afaik, JEE5 injection (@PersistenceContext, @EJB...) works only in container managed classes (EJB, servlet...), so if you want to inject JEE dependencies in other types of resources, frameworks such as Spring are still usefull, and especially whith the Spring 2.5 JEE namespace: you can declare a local/remote ejb from a business interface in one line of XML.
With respect to persistence, you'll have to use a JPA engine (essentially the one of your AS), so if you use JBoss 5 AS, you're in fact using Hibernate for JPA under the hood (Glassfish uses EclipseLink...)
I would say stick with the JEE norm whenever you can, more importantly if your client want a full Sun (soon to be Oracle) JEE stack (code your application against JPA and not Hibernate).
Agreed, JPA 1.0 lacks some interesting features found in Hibernate (notably the Criteria API), but JPA 2.0 and JEE6 are not far and will address this.

My 0.02

Christian


Christian Gossart
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

EJB 3 is certainly a handsome improvement from the past, but it doesn't exclude the need for a good framework like Spring.

I typically recommend JSF, EJB3 and Seam as a development platform, framework and philosophy. It's an easy sell to an architecture review board on a bank or insurance company. Smaller implementations might prefer something even more lightweight as there is a point where you get to 'framework-bloat.'

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB 3.0 + EntityManager or Spring
 
Similar Threads
Value List Handler
JPA's context injection with Hibernate as engine
Which one is better between EntityManager and getHibernateTemplate()?
How to create a Template for EntityManager in a WebApplication
PrePersist doesn't work with Hibernate Template