----- Original Message -----
From: Bill Siggelkow <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 28, 1999 1:02 PM
Subject: DB Helper classes for dependent data

I have a stateful session bean that wraps a CMP entity bean for persistence
services.  In the session beans 'save()' method it creates the CMP entity
bean and then creates some dependent data using a "helper class".  The
"helper class" provides data access to a table containing dependent data
for the CMP bean.  There is a foreign key constraint between the table
holding the dependent data and the OID of the CMP bean.  The helper class
is not an entity bean but simply gets a connection and inserts data into
the table using JDBC.  The problem I am having is that when I attempt to
insert the dependent data into the table I get a constraint violation -- at
first this seemed impossible since I create the CMP bean first ... however,
I realized that the problem is that the creation of the dependent data is
using the same connection as the CMP bean.  If I remove the constraint
everything works fine ...
Is there a way of getting the connection being used by the CMP bean?  Is
there a better approach to this problem other than (1) converting the CMP
bean to BMP, or (2) removing the database constraint, or (3) making the
dependent data a full-blown entity bean?


<Me>

         If it makes any logical sense in your model for the CMP bean to
exist first without the dependent data, you could separate the CMP bean
creation and the dependent data insert into two separate methods in the CMP
bean that your stateful session bean calls- like "save", "appendSomeData".

Regards,
Murali Krishna Devarakonda

</Me>



[...snip...]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to