• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Is this good design

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a previous project where we were using struts the action classes were making calls to methods defined in stateless session beans .

These bean methods were then making calls to static methods defined in a separate class - which we termed as our Business classes

These Business classes would interact with the database .

My question was - in case of retrieving data from the database - ( using select queries ) is it still necessary to make calls through the EJB Layer ?

In case of simply retrieving data is this not an overhead ?
What advantages/disadvantages does this approach incurr ?

Regards ,
-satish
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankly that sounds like an awful idea: calling static methods on *business* objects to interact with the databse. Where do I begin in describing what's wrong with this approach.

Firstly: static methods are effectively global so you've made you're entire app dependent on those classes.

Second: You've hard coded your dependency on those classes: you couldn't for example use another object that implements the same interface to substitue: how do you test? How do you migrate to another environment?

Third: Well third you're using EJBs but then let's just say EJB CMP is an abomination and BMP is worse...

Have look at Hibernate which is a brilliant ORM library: and in case you're desperate to stick with EJB (some kind of masochist huh?) then a) you can use Hibernate from Stateless Session beans and b) Gavin King, the lead dev for Hibernate, is also on the EJB 3.0 CMP committe and reports EJB 3.0 CMP will look an awful lot like Hibernate.

Edward

If JavaRanch had sigs mine would say: Burn EJB and their creators!
 
author & internet detective
Posts: 42103
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satish,
The decision of whether to go through the session bean layer depends on whether you need transactions/security/scalability.

I second that you should avoid the static calls. Even if you are stuck with them, create a wrapper to abstract it away.
 
Jeanne Boyarsky
author & internet detective
Posts: 42103
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edward,
JavaRanch actually does have sigs. If you edit your profile, it's the last item in the first section.
 
Edward Kenworthy
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeanne Boyarsky:
Edward,
JavaRanch actually does have sigs. If you edit your profile, it's the last item in the first section.



Yeah I know: I just thought my comment would be funnier if I pretended they didn't. Kind of like when Roger rabbit escapes from the handcuffs and Bob Hoskyns asks him why he didn't do it earlier: "because it wasn't funny then.". Oh well maybe not
 
Jeanne Boyarsky
author & internet detective
Posts: 42103
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edward,
Oh! I get it now. Sometimes it takes a while for a joke to sink in
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic