java - When can/should you go whole hog with the ORM approach? -
it seems me introducing orm tool supposed make architecture cleaner, efficiency i've found myself bypassing , iterating on jdbc result set on occasion. leads uncoordinated tangle of artifacts instead of cleaner architecture.
is because i'm applying tool in invalid context, or deeper that?
when can/should go whole hog orm approach?
any insight appreciated.
a little of background:
in environment have 50 client computers , 1 reasonably powerful sql server.
i have desktop application in 50 clients accessing data @ times.
the project's data model has gone through number of reorganizations various reasons including clarity, efficiency, etc.
my data model's history
- jdbc calls directly
- dao + pojo without relations between pojos (basically wrapping jdbc).
- added relations between pojos implementing lazy loading, hiding inter-dao calls
- jumped onto hibernate bandwagon after seeing how "simple" made data access (it made inter pojo relations trivial) , because decrease number of round trips database when working many related entities.
- since desktop application keeping sessions open long term nightmare ended causing whole lot of issues
- stepped partial dao/hibernate approach allows me make direct jdbc calls behind dao curtain while @ same time using hibernate.
hibernate makes more sense when application works on object graphs, persisted in rdbms. instead, if application logic works on 2-d matrix of data, fetching via direct jdbc works better. although hibernate written on top of jdbc, has capabilities might non-trivial implement in jdbc. eg:
- say, user views row in ui , changes of values , want fire update query columns did indeed change.
- to avoid getting deadlocks need maintain global order sqls in transaction. getting right jdbc might not easy
- easily setting optimistic locking. when use jdbc, need remember have in every update query.
- batch updates, lazy materialization of collections etc might non-trivial implement in jdbc.
(i "might non-trivial", because of course can done - , might super hacker:)
hibernate lets fire own sql queries also, in case need to.
hope helps decide.
ps: keeping session open on remote desktop client , running trouble not hibernate's problem - run same issue if keep connection db open long.
Comments
Post a Comment