I can a job table and a job class. The job table stores the project label. That is why it is listed as a primary key.
I have to set it up this way.
Can you help me with my problem?
Armin Waibel wrote:
Hi,
Project --1:n --> PrimaryInvestigator (PI) PK fields for Project: label fiscalYears why is 'id' not the PK in Project?
In PI FK are: projectId fiscalYear
projectId id not a PK in Project, you have to use a 'labelId'.
As a side-note, be really careful when using anonymous fields for fields other than 1:1 FK.
http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+
regards, Armin
Bobby Lawrence wrote:
Using the PersistenceBroker API...
I have a class that has a 1:n relationship -> a project can have many principal investigators.
The class descriptors look like this:
<class-descriptor class="org.jlab.mis.services.mics.client.generated.Project" table="projects">
<field-descriptor name="id" column="PROJECT_ID" jdbc-type="VARCHAR"/>
<field-descriptor name="label" column="REPO_CODE" jdbc-type="VARCHAR" primarykey="true" access="anonymous" />
<field-descriptor name="fiscalYear" column="FISCAL_YEAR" jdbc-type="VARCHAR" primarykey="true" />
<field-descriptor name="name" column="PROJECT_NAME" jdbc-type="VARCHAR" />
<collection-descriptor name="primaryInvestigators" element-class-ref="org.jlab.mis.services.mics.client.generated.PrimaryInvestigator" auto-retrieve="false">
<inverse-foreignkey field-ref="projectId" />
<inverse-foreignkey field-ref="fiscalYear" />
</collection-descriptor>
</class-descriptor>
<class-descriptor class="org.jlab.mis.services.mics.client.generated.PrimaryInvestigator" table="pis">
<field-descriptor name="id" column="PERSON_ID" jdbc-type="VARCHAR" primarykey="true"/>
<field-descriptor name="firstName" column="FIRSTNAME" jdbc-type="VARCHAR" />
<field-descriptor name="lastName" column="LASTNAME" jdbc-type="VARCHAR" />
<field-descriptor name="email" column="EMAIL" jdbc-type="VARCHAR" />
<field-descriptor name="fiscalYear" column="FISCAL_YEAR" jdbc-type="VARCHAR" access="anonymous" primarykey="true"/>
<field-descriptor name="projectId" column="PROJECT_ID" jdbc-type="VARCHAR" access="anonymous" />
</class-descriptor>
The problem is, whenever OJB tries to retrieve a collection of Primary Investigators, it never uses the correct value for the composite primary key.
The debugging output looks like this:
[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeQuery : QueryByCriteria from class org.jlab.mis.services.mics.client.generated.PrimaryInvestigator where [projectId = 13179, fiscalYear = 13179]
As you can see, it is using the exact same value for the projectId and fiscalYear attributes.
What am I doing wrong?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- ---------------------------- Bobby Lawrence MIS Application Developer
Jefferson Lab (www.jlab.org)
Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 ----------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]