Can I call you at the number below.. I will try and walk you through
this if I can.. Basically the trick is in the xml repository file..  I
just got this working so it is pretty fresh in my mind. It is not hard
just a little tricky.

I started to send you my code but it is huge.. Instead maybe it is
better for me to point you to an example which you already have. If you
download the source version of OJB you will find the test scripts. They
have a lot of really good things in there. The one that I used to get
this working for me was the NtoMapping. I think that it is in
src/test/org/apache/obj/broker...
Also on the web page there is a section called advanced OR mapping. Look
at the section which talks about collection-descriptors. This is how you
describe a Vector inside of an java data object. Now you are lucky
because the intermediate table only contains the ids of the two tables
you are mapping.. This is the easier case. I have to run right now but
take 
A few minutes and take a peek there. Just get one way working the other
way is exactly the same.


------------------ data object definition
package com.cadence.apps.cadencepdk.model;

import java.util.Collection;
import java.util.Iterator;
import java.io.Serializable; 

public class UserPrivileges implements Serializable {  
    
    private int userID;
    private Collection documents;
    
    public UserPrivileges(){
    }
    
    public int getUserID(){
        return userID;
    }
    public Collection getDocuments(){
        return documents;
    }
    
    public void setUserID(int userID){
        this.userID = userID;
    }
    public void setDocuments(Collection documents){
        this.documents = documents;
    }
    
    public String toString(){
        String returnStr = "UserPrivileges userID=>" + userID + "\n";
        if (documents != null){
            Iterator objIter = documents.iterator();
            while (objIter.hasNext()){
                if (returnStr != null){
                    returnStr = returnStr + "\n" +
(Document)objIter.next();
                }
                else {
                    returnStr = "\n" + (Document)objIter.next();
                }
            }
        }
        else {
            returnStr = returnStr + "\n documents is NULL";
        }
        return returnStr;
    }
}

------------------------------------------ the query

    public Response execute(){        
        //  this give me all the docs this user can access. 
        //  with the filters you requested
        ResponseImpl response = null;
        List userAccessDocs = new Vector();
            UserPrivileges  userObj = new UserPrivileges();
                //      super criteria is just a criteria object which
filters the             //      results, for now you can just pass
null..  
            Query query = new QueryByCriteria(UserPrivileges.class,
super.criteria);

        try {
            broker.beginTransaction();
                        userObj = (UserPrivileges)
broker.getObjectByQuery(query);
                        userAccessDocs.addAll(userObj.getDocuments());
                        broker.commitTransaction();
        }
        catch (Exception exc) {
            exc.printStackTrace();
        }


IN THE XML FILE UNDER UserPrivileges

        <collection-descriptor name="documents" 
        
element-class-ref="com.cadence.apps.cadencepdk.model.Document"
                auto-retrieve = "true"
                auto-update = "false"
                indirection-table = "udaccess"> 
                <fk-pointing-to-this-class column="userid"/>
                <fk-pointing-to-element-class column="docid"/>
        </collection-descriptor>


I am sorry for the disorganized brain dump.. Listen if you need some
more help send me an email at [EMAIL PROTECTED] I will try and grab
some time and call you if I can.. Okay.. I ma just working like crazy
but I promised myself that if I got it working I would help someone else
get it working.. I got to run now though, let me know how this works out
for you.. :)

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

Reply via email to