You shouldn't use the primarykey of We as the foreignkey for the instance of Subject. The foreignkey will be filled with the primarykey value of the Subject instance when you store the We object and it has an associated Subject object.
Instead add an additional field to the We class, e.g. int subject_id, and use it for the foreignkey of the we attribute.


Btw, you should also use Integer instead of int for the primarykey (and foreignkey) field (has to do with the representation of an empty reference in the database).

Tom

Thanks for a quick reply. I corrected the classes as you suggested, but the problem remains :( Is there ill something else?

public class Subject
{
    /**
     * Artificial ID key holder
     *
     * @ojb.field nullable="false"
     *            autoincrement="ojb"
     *            primarykey="true"
     */
    private Integer a_id;

    public Subject()
    {
    }
}

public class We
{
    /**
     * Artificial ID key holder
     *
     * @ojb.field nullable="false"
     *            autoincrement="ojb"
     *            primarykey="true"
     */
    private Integer a_id;


public We() { }

    /**
     * @ojb.reference class-ref="test.Subject"
     *                foreignkey="master_id"
     *                auto-retrieve="true"
     *                auto-update="true"
     *                auto-delete="true"
     */
    public Subject we;

    /**
     * Referential ID key holder
     * Primary key, becouse only marks
     *
     * @ojb.field nullable="false"
     */
    private Integer master_id;
}

David

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



Reply via email to