-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Ok can't figure this out, and searching is leading me nowhere so far. Sorry if this seems basic, it doesn't seem like it, but it should be.
I've got 2 class descriptor blocks like these:
<class-descriptor class="com.codepuccino.security.beans.UserInfoBean"
table="CDPCNO_USER_INFO">
<field-descriptor name="userID" column="user_id" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
<field-descriptor name="firstName" column="first_name"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="midInit" column="mid_init" jdbc-type="VARCHAR"
nullable="true"/>
<field-descriptor name="lastName" column="last_name"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="email" column="email" jdbc-type="VARCHAR"
nullable="false"/>
<collection-descriptor
element-class-ref="com.codepuccino.security.beans.UserLoginBean"
name="userLoginColl" auto-retrieve="true" auto-update="true"
auto-delete="true" refresh="true">
<inverse-foreignkey field-ref="userID"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor class="com.codepuccino.security.beans.UserLoginBean"
table="CDPCNO_USER_LOGIN">
<field-descriptor name="userID" column="user_id" jdbc-type="INTEGER"
primarykey="true"/>
<field-descriptor name="loginName" column="username"
jdbc-type="VARCHAR" nullable="false"/>
<field-descriptor name="password" column="password"
jdbc-type="VARCHAR" nullable="true"/>
<reference-descriptor name="userInfoBean"
class-ref="com.codepuccino.security.beans.UserInfoBean"
auto-retrieve="true" auto-update="false" auto-delete="false">
<foreignkey field-ref="userID"/>
</reference-descriptor>
</class-descriptor>I am trying to insert data into both tables in one submit, and I'm miserably failing at: 1- Getting the UserLoginBean's userID to set based on the insert from UserInfoBean. 2- If the first insert to user info works, and the second fails, it seems to not rollback the first insert. So what I need is a way to not commit the transaction until the whole enchilada is done.
Some things I have: 1- UserLoginBean has variables and get/set methods for UserInfoBean 2- UserInfoBean has a Collection of userLoginColl
My struts action passes userLoginBean and userInfoBean objects to my OJB impl class called RegistrationDAOImpl. In RegistrationDAOImpl I do this:
public final void addRegistration( final UserInfoBean user, final
UserLoginBean userLoginBean )
throws DataAccessException
{
final Transaction tx = getOdmgImpl().newTransaction();
try
{
LOGGER.log( Level.FINEST, "Transaction open in " +
RegistrationDAOImpl.class.getName() );
tx.begin();
tx.lock( user, Transaction.WRITE );
userLoginBean.setUserID( user.getUserID() );
tx.lock( userLoginBean, Transaction.WRITE );
tx.commit();
}
catch( TransactionAbortedExceptionOJB tab )
{
throw DataAccessException.datastoreError( tab );
}
}The exception is that the primary key is null in UserLoginBean.
What's the right way to do this???
Thanks R -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD4DBQE/uFmP+cV9vuB27SARAvccAJdsQ8aJDfcGYlByfgT3utuBSukQAJ0TnnkC cBPSSQOs1ZRvDQtjHO6Tkw== =4Q26 -----END PGP SIGNATURE-----
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
