• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

design question

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Our product is a complex is a set of "sub-product".

My " sub -product " is the center of the product and responsible for catalog management.

Me and my work colleagues has an discussion if we should expose the hibernate model in the service layer or should we expose an interface in order to abstract the database structre.

The disadvantage in expose interface is the performance, complexity and etc .

What do you thinks?
 
Author
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're talking about a service layer that acts as an interface to external systems, you definitely don't want to expose your hibernate model. If you read through Martin Fowler's Patterns of Enterprise Application Architecture, he has a good discussion as to why you don't want to do this.

Primarily:
- You don't want to expose transactions to your client (avoid distributed transactions)
- You want your service layer to be coarse grained to avoid performance issues with distributed calls (no, this is not premature optimization, it is architecture)
- You want to eliminate duplication in code that the clients would have by stringing together find-grained data access calls.

 
avihai marchiano
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not external system.

My sub-product is responsible for manage the item catalog.
All other sub-products depend on the item catalog data, so i need to give them a service layer for getting data from the catalog.

Most of the " get data " are for bulk of entities.

The result of the service layer can be the same pojo of the hibernate or interface.

Disadvantage of expose the hibernate model:
1. you lost encapculation.
2. you expose the database structre
3. bad for refactor

Advantage of hibernate:
1. its easly to expose service layer for get, because they can use hibernate criteria for fetching.
2. easly for performance
3. no need to write complex adapter.
3.
 
reply
    Bookmark Topic Watch Topic
  • New Topic