Hi Wes,

Lemke, Wesley wrote:
We have a 1-1 relationship between GenericGroup and AccountTeam.
However, in the user interface, the GenericGroup is created on one page,
and the AccountTeam is added later on, on a different page.  Once we
create the AccountTeam Object, associate it with the correct
GenericGroup and then save, we are getting a FK error.

OJB seems to be trying to update the GenericGroup before it inserts the
AccountTeam.  Is there a way to control the order of the statements?
Even w/o the FK constraint, OJB should be inserting the AccountTeam
object first, because we are using database generated Ids.


The insert/update ordering in OJB is:

first store 1:1 references
store main object
store 1:n, m:n references

So if you store a Group object, OJB will find the 1:1 reference to Account and store this object first (when storing Account OJB again check references for ordering).
But in


>    <reference-descriptor name="accountTeam"
> class-ref="com.lmig.pm.affinity.model.client.account.AccountTeam">
>            <foreignkey field-ref="accountTeamId"/>
>    </reference-descriptor>

you don't set auto-update="object" to force OJB to store the referenced object too.

http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3A1+auto-xxx+setting

If you need a different order you have to insert the objects in two steps, e.g. first store Account, then set Group reference in Account, store Account again to link Account and store Group (or store Group, then store Account, if auto-update is link/false).

regards,
Armin

Here is the relevant portion of the mapping document and stack trace:

<class-descriptor class="com.lmig.pm.affinity.model.client.NewClientGroup"
table="DEXA400T"
>
...
<field-descriptor
name="accountTeamId"
column="ACCT_TEAM_ID"
jdbc-type="INTEGER"
access="anonymous"
/>
<reference-descriptor name="accountTeam"
class-ref="com.lmig.pm.affinity.model.client.account.AccountTeam">
<foreignkey field-ref="accountTeamId"/>
</reference-descriptor>
...
</class-descriptor>


<class-descriptor
class="com.lmig.pm.affinity.model.client.account.AccountTeam"
table="DEXA540T"
>
<field-descriptor
name="objectId"
column="ACCT_TEAM_ID"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
access="readonly"
/>
<field-descriptor
name="accountManagerId"
column="ACCT_MGR_ID"
jdbc-type="INTEGER"
access="anonymous"
/>
<reference-descriptor name="accountManager"
class-ref="com.lmig.pm.affinity.model.client.account.AccountManager">
<foreignkey field-ref="accountManagerId"/>
</reference-descriptor>

<field-descriptor
name="araId"
column="ARA_ID"
jdbc-type="INTEGER"
access="anonymous"
/>
<reference-descriptor name="ara"
class-ref="com.lmig.pm.affinity.model.client.account.AccountRelationsAss
ociate">
<foreignkey field-ref="araId"/>
</reference-descriptor>

<field-descriptor
name="managementLevelId"
column="ANT_MGT_LEV_ID"
jdbc-type="INTEGER"
access="anonymous"
/>
<reference-descriptor name="managementLevel"
class-ref="com.lmig.pm.affinity.model.client.account.AccountManagementLe
vel">
<foreignkey field-ref="managementLevelId"/>
</reference-descriptor>


<collection-descriptor
name="salesReps"
element-class-ref="com.lmig.pm.affinity.model.client.account.SalesRepres
entative"
auto-delete="true"
auto-update="false"
>
<inverse-foreignkey field-ref="accountTeamId" />
</collection-descriptor>

<field-descriptor
name="idOfLastUserToUpdate"
column="LAST_MODIFIED_USER"
/>
<field-descriptor
name="lastModifiedDate"
column="LAST_MODIFIED_DTM"
jdbc-type="TIMESTAMP"

conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTi
mestampFieldConversion"
/>
<field-descriptor
name="objectStatus"
column="ROW_STTS_FLAG"
/>
<!-- Field used for OJB's Optimistic Locking -->
<field-descriptor
name="optLockField"
column="OP_LOCK_ID"
jdbc-type="INTEGER"
locking="true"
/>
</class-descriptor>



[5/10/05 12:39:33:441 CDT] 6dbd6dbd SystemOut O The broker was not
in transaction - nothing will happen
[5/10/05 12:39:33:591 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:591 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:642 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:642 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:732 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:742 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:832 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:832 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:932 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:932 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:972 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:33:972 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:032 CDT] 6dbd6dbd SystemOut O Store successful
[5/10/05 12:39:34:122 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:132 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:232 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:232 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:343 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:343 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:443 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:34:443 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG:
SQL:UPDATE AD2STDDE.DEXA580T SET
STATUS_ID=?,TMN_REASON_ID=?,EFF_DT=?,PREVIOUS_EFF_DT=?,PREVIOUS_STATUS_I
D=?,LAST_MODIFIED_USER=?,LAST_MODIFIED_DT=?,ROW_STTS_FLAG=?,OP_LOCK_ID=?
WHERE AGR_STATUS_ID = ? AND OP_LOCK_ID = ? [5/10/05 12:39:34:443 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:57:746 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
3932,ACCOUNT TEAM TEST 3,100 Liberty Way,,Dean Thurs,Tue May 10 00:00:00
CDT 2005,null,code: 1 value: Client
Group,,LOBs:0,MLs:1,null,null,com.lmig.pm.affinity.model.client.NewClien
tGroup,null,null,Group Savings
Plus,[EMAIL PROTECTED],null,VIPs:0,code:
2 value: Employer Group,,null,true,true,SGs:0
[5/10/05 12:39:57:746 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG:
SQL:UPDATE AD2STDDE.DEXA400T SET
CLIENT_ID=?,CATEGORY_TYPE_ID=?,INN_CLIENT_NB=?,ETL_CLIENT_ID=?,SDD_COMP_
I=?,PRIMARY_GRP_I=?,ELIGIBLES_ID=?,CLIENT_BILLING_ID=?,ACCT_TEAM_ID=?,PR
OGRAM_NM=?,NAME=?,LAST_NAME=?,LAST_NAME_DT=?,KEY_WORDS=?,EFF_DT=?,COMMEN
TS=?,MAIL_MEMBERS=?,REPORTS_ID=?,type_id=?,REPORTS_DESC=?,ADDRESS_ID=?,C
ONTACT_ID=?,AGR_STATUS_ID=?,CLASS_NAME=?,LAST_MODIFIED_USER=?,LAST_MODIF
IED_DTM=?,ROW_STTS_FLAG=?,OP_LOCK_ID=? WHERE GENERIC_GRP_ID = ? AND
OP_LOCK_ID = ? [5/10/05 12:39:57:746 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeUpdate:
[EMAIL PROTECTED]
[5/10/05 12:39:58:417 CDT] 6dbd6dbd SystemOut O
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
during the execution of the update (for a
com.lmig.pm.affinity.model.client.NewClientGroup): [IBM][CLI
Driver][DB2] SQL0530N The insert or update value of the FOREIGN KEY
"ACCT$TEA" is not equal to any value of the parent key of the parent
table. SQLSTATE=23503


[5/10/05 12:39:58:417 CDT] 6dbd6dbd SystemOut     O [IBM][CLI
Driver][DB2] SQL0530N  The insert or update value of the FOREIGN KEY
"ACCT$TEA" is not equal to any value of the parent key of the parent
table.  SQLSTATE=23503

[5/10/05 12:39:58:417 CDT] 6dbd6dbd SystemErr     R
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0530N  The
insert or update value of the FOREIGN KEY "ACCT$TEA" is not equal to any
value of the parent key of the parent table.  SQLSTATE=23503

[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
java.lang.Throwable.<init>(Throwable.java)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
java.lang.Throwable.<init>(Throwable.java)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
java.sql.SQLException.<init>(SQLException.java:51)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.DB2Exception.<init>(DB2Exception.java:72)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExcepti
onGenerator.java:270)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExcepti
onGenerator.java:207)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptio
nGenerator.java:458)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2PreparedStatement.
java)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(DB2PreparedState
ment.java:1642)
[5/10/05 12:39:58:437 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPr
eparedStatement.java:555)
[5/10/05 12:39:58:447 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeUpdate(Unknown
Source)
[5/10/05 12:39:58:447 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown
Source)
[5/10/05 12:39:58:447 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
[5/10/05 12:39:58:447 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)
[5/10/05 12:39:58:447 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
[5/10/05 12:39:58:457 CDT] 6dbd6dbd SystemErr     R     at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown
Source)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.persistence.PersistenceManager.save(PersistenceMana
ger.java:338)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.persistence.PersistenceManager.saveList(Persistence
Manager.java:1244)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.persistence.PersistenceManager.saveList(Persistence
Manager.java:1262)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.action.AffinityAction.persistAdmObject(AffinityActi
on.java:575)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.action.SaveClientPageThreeAction.doPerform(SaveClie
ntPageThreeAction.java:84)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.action.AffinityAction.execute(AffinityAction.java:1
32)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
ocessor.java:484)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
274)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.lmig.pm.affinity.servlet.ActionServlet.doPost(ActionServlet.java:79)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictSe
rvletInstance.java:110)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLi
fecycleServlet.java:174)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycle
Servlet.java:313)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLif
ecycleServlet.java:116)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.
java:283)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(Vali
dServletReferenceState.java:42)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(Servle
tInstanceReference.java:40)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispa
tch(WebAppRequestDispatcher.java:948)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRe
questDispatcher.java:530)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppReq
uestDispatcher.java:176)
[5/10/05 12:39:58:467 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:7
9)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInv
oker.java:201)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocati
on(CachedInvocation.java:71)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(Servle
tRequestProcessor.java:182)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSELis
tener.java:334)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection
.java:56)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:
610)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.http.HttpConnection.run(HttpConnection.java)
[5/10/05 12:39:58:477 CDT] 6dbd6dbd SystemErr     R     at
com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to