> Now on to another issue.
> 
> /**
>  * @ojb.class table="CA_PROJECT_T"
>  */
> public class ProjectCode {
>   /**
>    * @ojb.field column="PROJECT_CODE"
>    * jdbc-type="VARCHAR" primarykey="true"
>    */
>    private String code;
> }
> 
> ---
> 
> /**
>  * @ojb.class table="PROJ_DOC" include-inherited="true"
>  */
> public class ProjectCodeDocument extends ProjectCode implements
> SubClassOfDocument {
> }
> 
> ---
> 
> When I run the XDoclet OJB Ant task on this source tree I get:
> 
> xdoclet.XDocletException: The number of foreignkeys (1) of the reference
> projectCode doesn't match the number of primarykeys (2) of the
> referenced class (or its subclass) org.my.bo.ProjectDocument.
> 
> ---
> 
> Now the trick here is that nothing refers directly to
> ProjectCodeDocument. The Java code only ever refers to ProjectCode
> instances.  ProjectCodes will only ever be looked up by their "code"
> field. ProjectCodeDocuments will only ever be looked up by their
> documentHeaderId.
> 
> In fact there are no references (yet) in the source tree to
> ProjectCodeDocument at all.
> 
> So is it the case that if B extends A, A declares a primary key, and B
> declare a different primary key, all lookups of instances of B must be
> done by BOTH primary keys?

The XDoclet module checks that the foreignkey relation
(reference/collection) is correct for every type that may be
referenced/may be referencing. E.g. if you have a reference to type B
than it is checked that the number and jdbc types of the primary keys
match those of the foreign keys used in the reference (similarily for
collections).

You should not change the primary key in a sub type if you have the
inheritance in the repository description because this will surely
lead to problems at runtime. Either you use composite primary keys or
you remove the inheritance specification in the repository file (using
the determine-extents attribute of the ojb.class tag in the base
type).

Tom

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

Reply via email to