Java Persistence/Why use JPA or ORM?

Why use JPA or ORM?Edit

This is an intriguing question. There are many reasons to use an ORM framework or persistence product, and many reasons to use JPA in particular.

Reasons for ORMEdit

  • Eliminates all of the 'hand' mapping in Java from a SQL ResultSet to a Java POJO greatly reducing the amount of mapping work.
  • Reduces the amount of work required to the persistence code base with a domain data model and/or relational data model change.
  • Leverages large persistence library to avoid developing solutions to problems that others have already solved.
  • Avoids low level JDBC and SQL code.
  • Leverages object oriented programming and object model usage.
  • Provides database and schema independence.
  • Most ORM products are free and open source.
  • Many enterprise corporations provide support and services for ORM products.
  • Provides high end performance features such as caching and sophisticated database and query optimizations.

Reasons for JPAEdit

  • It is a standard and part of EJB3 and Java EE.
  • Many free and open source products with enterprise level support.
  • Portability across application servers and persistence products (avoids vendor lock-in).
  • A usable and functional specification.
  • Supports both Java EE and Java SE.

ORM can be a hot topic for some people, and there are many ORM camps. There are those that endorse a particular standard or product. There are those that don't believe in ORM or even objects in general and prefer JDBC. There are those that still believe that object databases are the way to go. Personally I would recommend you use whatever technology you are most comfortable with, but if you have never used ORM or JPA, perhaps give it a try and see if you like it. The below list provides several discussions on why or why not to use JPA and ORM.

Discussions on JPA and ORM UsageEdit