Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to to decide whether to go for ORM or simple JDBC?

 
Vee Sam
Greenhorn
Posts: 1
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We usually decide based on the factors like performance requirement, application development time, SQL complexity and maintainability. However I just wanted to know is there any mathematical formula (For example using number of tables, number/strength of its relations and so on) to recommend to use ORM, or any standard bench mark available to decide this?
 
Fernando Franzini
Ranch Hand
Posts: 489
2
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We usually decide based on the factors like performance requirement, application development time, SQL complexity and maintainability.

you be right! That is the way ...

However I just wanted to know is there any mathematical formula (For example using number of tables, number/strength of its relations and so on) to recommend to use ORM, or any standard bench mark available to decide this?

This issue is complicated and polemical ...
1. JDBC is unquestionably faster than ORM to have fewer layers of indirect services ..
2. But...ORM can have better performance than the JDBC if used properly through the high end features like Eager/Lazy loader, L1 and L2 Cache etc..
There is no exact "silver bullet" ...
You as an architect is responsible for resolving such situations and make your decision based on justifications consistently ...

Tips:

JDBC
Advantages:
- Best performance with explicitly tunning SQL by hand.
- is faster cause acess directly SGDB.
Disadvantages:
- longer, hard development and tests durations with explicit code SQL.

JPA
Advantages:
- isolate application from the database.
- increase manageability of application.
- improve developer productivity.
- ease of development generated correct and effecient persistence logic.
- can outperform hand-crafted SQL, reducing the number of database round-trips.
- jpa entities can be used outside container environment hence promoting re-usability and coding effort.
- jpa entities an be used on both presentation layer and business logic layer, thus reducing coding effort, size of code and maintenance cost associated
- supports lazy loading of objects hence improving performance.
- best integration with EJB 3.
- Used when model has complex relationships between tables.
Disadvantages:
- imply loss of performance cause include additional layer.
- can not explicitly tunning SQL by hand.
- when datastore is not welll suported by ORM providers.
- Developers need skilled in ORM (learnig curve).

You can read all stuff - http://fernandofranzini.files.wordpress.com/2012/07/ocmjea-jee5-1z0-8641.pdf

Best Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic