• 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:

help needed with calling a stored procedure from CMP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everybody,

I have two concerns to put forward.

1) We are working on a project in which we need to use Entity beans (CMP). There is no problem with sending & getting data.

But we have a stored procedure to be called in the mean while in the business logic of the CMP:

For achieving this do we need to acquire a new database connection other than which the existing entity is using?

Is this a good practice to do this way?

Also writing a BMP here increases the code complexity & makes our application tightly coupled with the database. Which we don�t want.

2) Can we achieve the same functionality of BMP with a CMP?

I invite any suggestions or advices, as I�m new to enterprise Java. Please give a response as soon as possible because we are on the nick of the moment to deliver a solution.

Any help in this regard would be greatly appreciated.



regards,

Raju Cherukuri.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raju, I may not be able to give an exact answer (never faced this exact situation) but thought would express my opinion/understanding of the situation.

A single entity bean (either BMP or CMP) instance essentially represents one single row (may be that of a single table incase of a CMP or of a join of multiple tables incase of a BMP) w.r.to the database.

When you are saying "we have a stored procedure to be called in the mean while in the business logic of the CMP", I am slightly confused. What we essentially do on a CMP entity bean is that we get and set values after obtaining a remote interface bandle of it. Is it that - in one of the setter method, you are required to call a stored procedure ?

If you donot want to disturb your existing CMP, my suggession would be that you define a database trigger on that table for BEFORE/AFTER UPDATE and 'call' that stored procedure. So when you 'set' a value on that CMP bean, that correspondig 'update' would trigger/call that stored procedure. For the transaction mgmt, if the stored procedure fails it throws an exception (assuming it would) and sure the trigger would fail and therefore the 'update' should fail and throw an database trigger failure exception. Not sure if the remote interface would throw us that exception (I assume it would).

I am not sure how to achieve this with a BMP but without acquiring a seperate database connection.
Can we define a new Entity Bean to represent a 'call to store procedure' ? And then obtain its remote interface which can call the stored procedure in our entity bean setter method ?
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic