OJB-users:
I would like to order a <collection-descriptor> based on the value of a
column in an indirection table. For instance, if a BOOK has an m:n
relation to AUTHORS specified via the indirection BOOK_AUTHOR_CROSS, and
BOOK_AUTHOR_CROSS has columns:
BOOK_ID,
AUTHOR_ID,
AUTHOR_ORDER
I would like the Collection of AUTHORS for a given book to be ordered by
the natural ordering of column AUTHOR_ORDER.
I've found previous list posts that recommended that I do this via the
orderby attribute in the collection-descriptor like this:
<collection-descriptor
name="authors"
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
element-class-ref="package.name.Author"
indirection-table="BOOK_AUTHOR_CROSS"
auto-update="none"
auto-delete="none"
orderby="BOOK_AUTHOR_CROSS.AUTHOR_ORDER"
proxy="true">
<fk-pointing-to-this-class column="BOOK_ID" />
<fk-pointing-to-element-class column="AUTHOR_ID" />
</collection-descriptor>
However, the SQL generated (from SQLGeneratorDefaultImpl) for the
Collection look-up does not contain an "order by" clause, the collection
is definitely not ordered properly, and changing the orderby attribute to
a bogus column name does not throw an error (ie.
BOOK_AUTHOR_CROSS.AUTHOR_ORDER_BOGUS) as I would expect it to do if it was
being used.
I understand from the repository.dtd documentation that the orderby
attribute is supposed to reference a <field-descriptor> on the
element-class, but I thought OBJ used to support this alternate form of
ordering for non-decomposed mappings.
Thanks,
Jon French
Programmer
ECOS Development Team
[EMAIL PROTECTED]
970-226-9290