hi bobby,

http://marc.theaimsgroup.com/?l=ojb-user&m=110504711807796&w=4

an example can be found in NoPkReferenceTest

jakob

Bobby Lawrence schrieb:
Jakob -
Where can I find info about this new feature?

Jakob Braeuchi wrote:

hi bobby,

your problem could be solved by the new relationship-definitions based on non-pk-fields.
this feature is available in the cvs trunk for ojb 1.1


Armin Waibel schrieb:

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]



--------------------------------------------------------------------- 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