You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Mike Perham <mp...@gmail.com> on 2006/09/01 16:59:10 UTC

Problem with Anonymous keys in 1.0.4

I'm having trouble getting a simple anonymous key example working in
my tests.  My class descriptor is something like this:

    <class-descriptor class="domain.ChangeStatus" table="gov_change_status">
        <field-descriptor id="1" name="id" column="id"
jdbc-type="INTEGER" nullable="false" primarykey="true"
access="readonly" autoincrement="true" />
        <field-descriptor id="2" name="statusId" column="status_id"
jdbc-type="INTEGER" nullable="false" access="anonymous" />
        <field-descriptor id="3" name="changeSubmissionId"
column="change_submission_id" jdbc-type="INTEGER" nullable="false"
access="anonymous" />

        <reference-descriptor name="status" class-ref="domain.StatusMaster">
            <foreignkey field-ref="statusId" />
        </reference-descriptor>
        <reference-descriptor name="changeSubmission"
class-ref="domain.ChangeSubmission">
            <foreignkey field-ref="changeSubmissionId" />
        </reference-descriptor>
    </class-descriptor>

My Java class looks roughly like this:

public class ChangeStatus extends BaseObject {

//    private int statusId;
//    private int changeSubmissionId;

    private StatusMaster status;
    private ChangeSubmission changeSubmission;

    // setters and getters...
}

The Desk and Drawer example says to add access="anonymous" to the
field descriptor and it should start to work but I consistently get
this error:

* SQLException during execution of sql-statement:
* sql statement was 'INSERT INTO gov_change_status
(status_id,change_submission_id,date_created,date_modified) VALUES
(?,?,?,?) '
* Exception message is [Column 'STATUS_ID'  cannot accept a NULL value.]
* Vendor error code [30000]
* SQL state code [23502=NOT NULL VIOLATION]
* Target class is 'domain.ChangeStatus'
* PK of the target object is [id=0]
* Source object:
domain.ChangeStatus@959fa1[status=domain.StatusMaster@19e3e24[type=Submitted,subType=Dummy,labelForType=<null>,description=Acknowle
dgement of Receipt of Change
Request,externalStatus=true,dateCreated=2006-09-01
09:44:09.592,dateModified=2006-09-01
09:44:09.592,id=15],changeSubmission=domain.ChangeSubmission@12342ed[requestId=request_id,catalogVersion=100,submittedBy=mperham,submissionDate=Fri
Sep 01 09:44:09 CDT 2006,commitDate=<null>,shortDescription=Short
desc,longDescription=Long
desc,externalGovId=<null>,changeStatuses=[],topLevelElements=[],externalSubmissions=[],dateCreated=2006-09-01
09:44:09.592,dateModified=2006-09-01
09:44:09.592,id=1],changeApprovals=<null>,changeDocuments=<null>,dateCreated=2006-09-01
09:44:09.733,dateModified=2006-09-01 09:44:09.733,id=0]

If I create and set the FK ID fields explicitly (the commented out
fields in the java code above), it works fine.  What am I missing?

mike

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org