Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Brooklyn Smith   on Apr 18 In Java Category.

  
Question Answered By: Laura Rodriguez   on Apr 18

I had lots of problems  with hibernate  2, and lots of other ORM and data  Access technologies  
DAL generators and not to forget and also ejb  2.1 entity  beans, but I find JPA (and Hibernate 3 and other JPA implementations) very easy and useful.
under Java EE 5, teaching JPA takes near 2 hour of time, and I had novice developers using it.

obviously adding any layer  to architecture  will reduce the performance, but I am sure the performance penalty of most ORMappers is less than other widely used technologies like Struts, EJB or even Spring Container.

I guess most of people unhappy with hibernate were using version 2 or version 3 with xml mappings, not hibernate as a JPA under Java EE 5 with annotations. (please correct me if I am wrong friends)

theoretically a good  OR Mapper should do the work better than a human, (assuming there exist any) both in optimization and saving developers time.

IMHO (In My Humble Opinion)
ORM or other technologies highly depends on the software process and architecture
ORM fills well into object oriented designs, which DB is a reflection of object model.
ORM fails if you have a RDBMS based design  (very optimized tables with stored procedures, etc)
ORM is not good if your platform or component model uses non object based data sources like XML data sources of .Net
in such a cases it is better not to use an Object Model at all, in data layer.
ORM has overhead using RDBMS
ORM can work on persistence technologies other than RDBMS like Object Spaces.

for those who don't know JPA, if you have a Java EE 5 container, the only thing you need to add your Java object to make it persistable is adding @Entity annotation to class and annotating primary key by @Id annotation.

if you want to work with Persistance Layer you just inject it with @EntityManager annotation like this:
@PersistenceContext
private EntityManager em;

and then in your ejb you can save your object like this:
em.persist(em);
the rest of the CRUD operations are nearly as easy as this.

the one to many and many to many relations are handled easily using annotations, and you have control over lazy loading or eager fetch strategy of relations.

the JPA cheet sheet is two page a4, which is less than JSP, Struts, CSS, JavaScript and lots of popular technologies.
and if you have still some problems with JPA 1, JPA 2 solves some of them, check JSR 303 (although most of them comes from hibernate ideas like validation)

Share: 

 

This Question has 23 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hibernate vs JPA Or get search suggestion and latest updates.


Tagged: