Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Using ORM frameworks in JEE applications instead of direct DB access... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Using ORM frameworks in JEE applications instead of direct DB access..." Watch "Using ORM frameworks in JEE applications instead of direct DB access..." New topic
Author

Using ORM frameworks in JEE applications instead of direct DB access...

Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

DB is a powerful entity. The DB product vendors provide all possible optimization, performance, fault tolerance etc...

StoredProcedures are yet another powerful entity, which is rarely used nowadays.
The propaganda of having to maintain Business Logic in the DB to avoid the possibility of moving from one DB vendor to another.
Moving to different DB vendors is a rare scenario in normal Business cases.

Considering the above, why is there a need at all, to use any ORM framework in any JEE application, when calls can be made to the DB through a DAO layer of classes (of course using Connection Pools)?

I am unconvinced that, you can test only the ORM framework propaganda. Can't the StoredProcedures be tested? It is just that, the testing will have to be carried out in non-Java. This is not a reason, not to use the power and efficiency offered by DB.


S.D. MADHAN
Not many get the right opportunity !
Marco Masi
Greenhorn

Joined: Apr 18, 2009
Posts: 7
The fast answer is: to not reinvent the square wheel.

ORM provides fast and easy ways to handle data stored on RDBMS hiding a huge part of this task complexity. JPA2 api is simple to understand and use and frameworks relieve you of lot of work. There are obviously drawbacks (you aren't really in complete control of database as you can be handling it by hand) but advantages outstrip them (nearly transparent transactions, JPQL standardized query language really object oriented...).

For medium and big projects I can't anymore think about use a database without an ORM... even for small projects I don't see a real advantage to use plain JDBC directly.

The propaganda of having to maintain Business Logic in the DB to avoid the possibility of moving from one DB vendor to another.
Moving to different DB vendors is a rare scenario in normal Business cases.

Yes DB vendor swapping doesn't happen very much (though I've already seen moving from MSSQL to MySQL and Oracle to MySQL... they were both cost cutting driven... and both a real pain in the ass) but I don't think that is the bigger reason to avoid as much business logic as possible on stored procedures. In my opinion changing a stored procedure is a much more delicate task than changing java code then better to go on the safest way.

I am unconvinced that, you can test only the ORM framework propaganda. Can't the StoredProcedures be tested? It is just that, the testing will have to be carried out in non-Java.

Probably stored procedures can be tested but surely is easier test java code (and for that probably it will be tested better too).

This is not a reason, not to use the power and efficiency offered by DB

Noone prevents you to get the best of both worlds... easy management for normal task and highly efficient procedures for that (really) small portion of code that need it (do you remember that "Pareto principle"?). But I have to admit that proceeding like that could lead to really ugly code...


Then, in my opinion, ORM (and frameworks in general) let the developer to focus on business logic shortening development time.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Moving to our ORM forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Using ORM frameworks in JEE applications instead of direct DB access...
 
Similar Threads
Jasper with StoredProcedures
Issue with BatchExection of CallableStatement with StoredProcedures in DB2
unable to roll back storedprocedures,,
StoredProcedures
Storedprocedures returns cursor