Hello Robert,
Would it work to simply let userLoginBean reference User in the repository_user.xml?
Then you would simply store the bean, and ojb would do the rest. Example:
<class-descriptor
class="...UserLoginBean"
table="userbeantable"
>
<field-descriptor
name="id"
column="Id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor
name="userId"
column="UserId"
jdbc-type="INTEGER"
/>
<reference-descriptor
name="user"
class-ref="...User"
>
<foreignkey field-ref="userId"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="...User"
table="usertable"
>
<field-descriptor
name="id"
column="Id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
</class-descriptor>
----------------------------------------------------------------
Bob Celestino
SAS Research and Development
919 - 531 - 9425
[EMAIL PROTECTED]
SAS - The Power to Know
> -----Original Message-----
> From: Robert S. Sfeir [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 14, 2003 7:34 PM
> To: OJB Users List
> Subject: OJB NPE On Double Table Insert
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Folks,
>
> I'm trying to do an double insert in 2 tables and for some
> reason I'm getting a NullPointerException. The way I go
> about it is below:
>
> //Open transaction
> tx = getOdmgImpl().newTransaction();
>
> //Transaction begins
> tx.begin();
> //Do first Insert
> tx.lock( user, Transaction.WRITE );
> //Get User ID after insert and set it in the second Bean
> userLoginBean.setUserID( user.getUserID() ); //Do second
> insert tx.lock( userLoginBean, Transaction.WRITE );
> //commit tx.commit();
>
> The problem, from my debugging investigation, is that OJB
> seems to think that userID is empty, it's not, because as I
> was stepping through the debugger, I could see that
> userLoginBean.getUserID() returned a correct value, the one
> from the first insert.
>
> I do have a catch clause so that if an exception is thrown
> it will do
> tx.abort() but it seems that if I don't catch some
> exception, like one I haven't accounted for yet, and an
> exception gets thrown, then the first insert is commited
> anyway... Is this correct behavior?
>
> Is this the right way of doing a double table insert?
>
> Thanks
> R
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQE/tXRp+cV9vuB27SARAhy8AJ42hoS9ip23sLzhLmWbfE+8/obKSQCgrEpl
> xzk9G4JUM27njZMwn3iVoUs=
> =aiYd
> -----END PGP SIGNATURE-----
>
>
> ------------------------------------------------------------
> ---------
> 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]