Thanks, this did work, even using another field other than the foreign key fields of the indirection class (as in the field PERSON_PROJECT_SORTORDER in my original example).
However it only worked using java.util.Collection as the collection class. I do need to use java.util.Vector, but this gives an error (below). Someone reported something similar earlier:
http://archives.apache.org/eyebrowse/ReadMsg?listName=ojb-user@;jakarta.apache.org&msgId=456467
Any help would be most appreciated.
Phil
*** class snippet begin***
public class PBranchImpl extends PNodeImpl implements PBranch, Serializable {
protected Vector children;
public Collection getChildren() {
return children;
}
public void setChildren(Vector in) {
children = in;
}
...
*** class snippet end***
*** class repository_user snippet begin***
<class-descriptor
class="mond.phenomenon.impl.PBranchImpl"
...
<collection-descriptor
name="children"
element-class-ref="mond.phenomenon.impl.PNodeImpl"
proxy="true"
auto-retrieve="true"
auto-update="false"
indirection-table="P_PARENT_CHILD"
orderby="P_PARENT_CHILD.CHILD_ORDER"
>
<fk-pointing-to-this-class column="PARENT_ID"/>
<fk-pointing-to-element-class column="CHILD_ID"/>
</collection-descriptor>
*** class repository_user snippet end***
*** console output begin***
...
[DEFAULT] ERROR: Error in operation [set] of object [PersistentFieldPropertyImpl], getWriteMethod returned null
[DEFAULT] ERROR: Declaring class [mond.phenomenon.impl.PBranchImpl]
[DEFAULT] ERROR: Property Name [children]
[DEFAULT] ERROR: Property Type [java.util.Collection]
[DEFAULT] ERROR: anObject was class [mond.phenomenon.impl.PBranchImpl]
[DEFAULT] ERROR: aValue was class [org.apache.ojb.broker.accesslayer.CollectionProxy]
org.apache.ojb.broker.PersistenceBrokerException: getWriteMethod returned null
at org.apache.ojb.broker.metadata.PersistentFieldPropertyImpl.set(PersistentFieldPropertyImpl.java:114)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveCollection(PersistenceBrokerImpl.java:943)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveCollections(PersistenceBrokerImpl.java:969)
at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(RsIterator.java:418)
at org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:203)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1117)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1239)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1265)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBrokerImpl.java:1252)
at mond.phenomenon.PNodeTestPB.run(PNodeTestPB.java:88)
at mond.phenomenon.PNodeTestPB.main(PNodeTestPB.java:112)
*** console output end***
Jakob Braeuchi wrote:
hi phil, i tried to add an 'orderby' (NOT 'orderBy' ) to the descriptor of class Person of the ojb testcases:.. <collection-descriptor name="projects" orderby="PERSON_PROJECT.PROJECT_ID" element-class-ref="org.apache.ojb.broker.Project" auto-retrieve="true" auto-update="true" indirection-table="PERSON_PROJECT" > <fk-pointing-to-this-class column="PERSON_ID"/> <fk-pointing-to-element-class column="PROJECT_ID"/> </collection-descriptor> .. the resulting sql is as follows: SELECT A0.TITLE,A0.DESCRIPTION,A0.ID,PERSON_PROJECT.PROJECT_ID FROM PROJECT A0,PERSON_PROJECT WHERE (PERSON_PROJECT.PERSON_ID = ? ) AND PERSON_PROJECT.PROJECT_ID = A0.ID ORDER BY 4 hth jakob ----- Original Message ----- From: "Phil Warrick" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Thursday, October 31, 2002 5:54 AM Subject: orderby and non-composed M:N mappingHi, It seems that one cannot use orderby to order a collection that uses an intermediate table with a sort attribute, as in: <collection-descriptor name="projects" element-class-ref="org.apache.ojb.broker.Project" auto-retrieve="true" auto-update="true" indirection-table="PERSON_PROJECT" orderBy = "PERSON_PROJECT_SORTORDER" > <fk-pointing-to-this-class column="PERSON_ID"/> <fk-pointing-to-element-class column="PROJECT_ID"/> </collection-descriptor> </class-descriptor> where the field PERSON_PROJECT_SORTORDER is in the PERSON_PROJECT table and orders the Projects referred to by a Person (error message below). Is the only workaround to use a non-decomposed M:N mapping and expose a an intermediary Java class? Thanks, Phil [Error] repository_user.xml:469:8: Attribute "orderBy" must be declared for element type "collection-descriptor". -- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>-- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
-- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
