• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Combine Hibernate with hand-coded SQL

Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Our current application architecture exists of a Session Fa�ade (SLSBs) which dispatches requests to one or more local business objects (SLSBs). These business objects communicate with data access objects (DAOs) trough fine-grained interfaces. The data access objects are hand-written and contain SQL statements and calls to stored procedures (a Data Access Helper is used to abstract the low-level JDBC tasks).
We would like to start using Hibernate because of the better maintainability and the reduced code complexity in the data access layer. Currently, we are investigating the different possibilities to integrate Hibernate in our application architecture.
We decided to use Hibernate for every new project that will be developed in the future but we already have a lot of EJB-modules which are in development and need to be extended from time to time. Some of these modules contain lots of hand-coded DAOs and we don�t want to replace every JDBC DAO by a Hibernate DAO. Nevertheless, we would like to extend these modules with new Hibernate DAOs in stead of new JDBC DAOs.
Is it possible to combine Hibernate with these hand-coded DAOs whithout duplicating the persistence logic? It�s not the intention to make POJOs for entities that are already accessible through JDBC because that would increase the maintenance cost when the DB schema changes.
I expect several problems with this approach. For instance:
- foreign keys to entities, represented by legacy DAOs, aren�t available as POJOs
- the legacy DAOs can bypass the Hibernate cache resulting in stale data
- ...
Are there best practices (or frameworks) to use this mixed persistence strategy?

Kind regards
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic