Hi Robert,

I'm not an expert on this subject,
anyhow some notes to your posted repository
(maybe someone can correct me):

- attribute 'id' not necessary in class-descriptor
- attribute 'id' not necessary in field-descriptor
- attribute 'field-id-ref' is not necessary when attribute
'field-ref' is set too.

<class-descriptor class="com.codepuccino.security.beans.UserLoginBean"
proxy="dynamic" table="CDPCNO_USER_LOGIN">

        <field-descriptor name="userID" nullable="false"
column="USER_ID" jdbc-type="INTEGER" primarykey="true"/>

<field-descriptor name="loginName" nullable="false" column="USERNAME"
jdbc-type="VARCHAR"/>


<field-descriptor name="password" nullable="false" column="PASSWORD"
jdbc-type="VARCHAR"/>


        <field-descriptor name="passwordReminder" column="REMINDER_CLUE"
jdbc-type="VARCHAR"/>

<field-descriptor name="statusID" column="STATUS_ID" jdbc-type="INTEGER"/>

        <field-descriptor name="lastLogin" nullable="false"
column="LAST_LOGIN" jdbc-type="TIMESTAMP"/>

<field-descriptor name="baseRole" column="BASE_ROLE" jdbc-type="VARCHAR"/>

<field-descriptor name="infoID" column="INFO_ID" jdbc-type="INTEGER"/>

        <reference-descriptor name="userInfoBean"
        class-ref="com.codepuccino.security.beans.UserInfoBean"
        auto-update="false" auto-delete="false">
             <foreignkey field-ref="infoID"/>
        </reference-descriptor>
    </class-descriptor>


####### I replaced <foreignkey field-ref="userID" field-id-ref="1"/> by <foreignkey field-ref="infoID"/>

and add a new field-descriptor 'infoId', because you need a field-descriptor with a fk to UserInfoBean

If you don't want to declare a infoId field in your UserLoginBean
class, declare field to be 'anonymous':

<field-descriptor name="infoID" column="INFO_ID" jdbc-type="INTEGER" access="anonymous"/>

More info see
http://db.apache.org/ojb/howto-use-anonymous-keys.html



    <class-descriptor class="com.codepuccino.security.beans.UserInfoBean"
proxy="dynamic" table="CDPCNO_USER_INFO">

        <field-descriptor name="userID" nullable="false"
column="USER_ID" jdbc-type="INTEGER" primarykey="true"
autoincrement="true" />

        <field-descriptor name="firstName" nullable="false"
column="FIRST_NAME" jdbc-type="VARCHAR"/>

<field-descriptor name="lastName" nullable="false" column="LAST_NAME"
jdbc-type="VARCHAR"/>


<field-descriptor name="midInit" column="MID_INIT" jdbc-type="VARCHAR"/>

<field-descriptor name="nickname" column="NICKNAME" jdbc-type="VARCHAR"/>

        <collection-descriptor name="userLogins"
element-class-ref="com.codepuccino.security.beans.UserLoginBean"
auto-update="false" auto-delete="false">
            <inverse-foreignkey field-ref="userID"/>
        </collection-descriptor>

</class-descriptor>

You declare both classes as dynamic proxy, but in your
code you still use real class arguments

public final void addRegistration( final UserInfoBean user, final
UserLoginBean userLoginBean )

it's ok in that case, but don't forget to operate on
the interfaces when use dynamic proxies.

regards,
Armin


Robert S. Sfeir wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I am still trying to insert 2 beans into 2 separate tables, however bean
2 needs the userID from bean 1's insert.

I can't seem to find examples for this, and everything I try inserts the
first bean, seems to get the id after insert, I do a setUserID on the
second bean, then perform the insert, and I still get an exception that
user_id cannot be null.  It's NOT NULL!  I am pretty frustrated with
this.  It should be simple, it's not.  I've tried it with ODMG and with
PersistenceBroker, both return the same problem.

Further the first insert gets commited even though the transaction
commit is not called, and therefore I can't rollback any changes once
the second insert fails.

I'm using RC4.

Here is what my insert looks like:

    public final void addRegistration( final UserInfoBean user, final
UserLoginBean userLoginBean )
            throws DataAccessException
    {
        final PersistenceBroker broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
        try
        {
            LOGGER.log( Level.FINEST, "Transaction open in " +
RegistrationDAOImpl.class.getName() );

            broker.beginTransaction();
            broker.store( user );
            userLoginBean.setUserID( user.getUserID() );
            broker.store( userLoginBean );
            broker.commitTransaction();
        }
        catch( PersistenceBrokerException tab )
        {
            broker.abortTransaction();
            throw DataAccessException.datastoreError( tab );
        }
    }

XML:

<class-descriptor class="com.codepuccino.security.beans.UserLoginBean"
proxy="dynamic" table="CDPCNO_USER_LOGIN">
<field-descriptor id="1" name="userID" nullable="false"
column="USER_ID" jdbc-type="INTEGER" primarykey="true"/>
<field-descriptor name="loginName" nullable="false" column="USERNAME"
jdbc-type="VARCHAR"/>
<field-descriptor name="password" nullable="false" column="PASSWORD"
jdbc-type="VARCHAR"/>
<field-descriptor name="passwordReminder" column="REMINDER_CLUE"
jdbc-type="VARCHAR"/>
<field-descriptor name="statusID" column="STATUS_ID" jdbc-type="INTEGER"/>
<field-descriptor name="lastLogin" nullable="false"
column="LAST_LOGIN" jdbc-type="TIMESTAMP"/>
<field-descriptor name="baseRole" column="BASE_ROLE" jdbc-type="VARCHAR"/>
<reference-descriptor name="userInfoBean"
class-ref="com.codepuccino.security.beans.UserInfoBean"
auto-update="false" auto-delete="false">
<foreignkey field-ref="userID" field-id-ref="1"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="com.codepuccino.security.beans.UserInfoBean"
proxy="dynamic" table="CDPCNO_USER_INFO">
<field-descriptor id="1" name="userID" nullable="false"
column="USER_ID" jdbc-type="INTEGER" primarykey="true"
autoincrement="true" />
<field-descriptor name="firstName" nullable="false"
column="FIRST_NAME" jdbc-type="VARCHAR"/>
<field-descriptor name="lastName" nullable="false" column="LAST_NAME"
jdbc-type="VARCHAR"/>
<field-descriptor name="midInit" column="MID_INIT" jdbc-type="VARCHAR"/>
<field-descriptor name="nickname" column="NICKNAME" jdbc-type="VARCHAR"/>
<collection-descriptor name="userLogins"
element-class-ref="com.codepuccino.security.beans.UserLoginBean"
auto-update="false" auto-delete="false">
<inverse-foreignkey field-ref="userID"/>
</collection-descriptor>
</class-descriptor>


PLEASE what am I missing?  I'm going gaga here because I don't see the
problem.

R
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/uaZF+cV9vuB27SARAujIAJ9m8nJpgW5xVdN3OPb6ef9BlYSeHwCeMDUf
ob+buyLnTASop68nj+D8Tyg=
=mu+W
-----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]



Reply via email to