Discussions

EJB design: EJB and stored procedures.

  1. EJB and stored procedures. (5 messages)

    hi,
    I'm posting this discussion again as i haven't got any responsenses....can somebody pl respond....???
    I'm on a project where in I have a all the business logic and the tranasactions in the stored procs and we have COM components that call the stored procedures and scripts(ASP) to call COM components.
    We are planning to do the same using J2EE...I'm looking for inputs regarding the design of this.
    Where to call Stored procedures from....etc...
    Thanks in advance...
    suzi lu

    Threaded Messages (5)

  2. EJB and stored procedures.[ Go to top ]

    Suzi,

    to begin with, using Store Procedures may not be the best design solution. The whole idea behind creating EJB components is to introduce the concept of component reusability across the applications and even environments. Using Stored Procedures does not fit with this notion because you include a part of business logic into the database layer instead of keeping it in the component layer.

    This said, I'd like to add that the question you pose is not a complete one. There is a lot of thought that goes into properly designing a J2EE application. You need to decide what Entity and Session Beans you will have and how they will collaborate with each other and the backend store; you need to decide how the JSPs interact with the EJBs; and so on. Read the Patterns section of this Web site to get an idea of what design patterns should/can be used to help you with the design decisions. You may also want to read a book that would help you understand what kind of things you should and should not do while designing a J2EE system.

    Leo
  3. EJB and stored procedures.[ Go to top ]

    Hi,
    Thanks a lot for the reply....
    I dounderstand that using stored procedured make the business logic settle down in the database layer and reduces reusability....but can we handle all the complex transactions and complexities in database manipulation using the finder methods in entity beans???
    I mean can the complex logic in the stored procs be handled with cmp???
    I am not rigid on using the stored procderes ...it's just that my appliaction was built that way....Any suggestions regarding the re design are evry much welcome.
    Tx,
    Suzi
  4. EJB and stored procedures.[ Go to top ]

    Hi:
    In my personal view point, You may develope your own stateless ejb which can be used to call the store procedure you have already had. Leave the ejb xml file with no container management of transactions. If you really want the flexibility of ejb management, you should remove the transaction code only from the stored procedures, and reset the ejb xml with method level of transaction instead.

    Good luck!

    Frank
  5. EJB and stored procedures.[ Go to top ]

    HI,
    the other way would be dump all the stored procedures and put all the sql code using bmp...
    is this approach good???
    Pl help me with suggestions...
    Tx,
    Suzi
  6. EJB and stored procedures.[ Go to top ]

    You can certainly copy the code from stored procedures into SQL statements and use them from the Beans. This, however, will require some work since you will need to place the logic from stored procedures into your Bean code.

    As far as designing EJBs is concerned, take a look at this discussion thread. It has a pretty good tips about deciding what Beans to use where.

    Leo