I have a two classes:
Employee (contains position and tasks) that extends Person (contains name,
id and a timestamp).

Using the following OQL:
SELECT e.name FROM castordemo.bdo.Employee e WHERE name LIKE $1

failed with an exception in OQLQueryImpl$OQLEnumeration.followPath() that
the path (e.name) was not found.
I think the problem is that followPath() only looks in the current class but
not in the base class.

The following path helped:

       private Object followPath(Object parent) {
            //System.out.println("Following the path.");
            //follow the path
            JDOClassDescriptor curClassDesc = _classDescriptor;
            Object curObject = parent;
            for ( int i = 1; i < _pathInfo.size(); i++ ) {
                String curFieldName = (String) _pathInfo.elementAt(i);
                try {
                    // MER: search also all base classes
>                    JDOFieldDescriptor curFieldDesc = null;
>                   while (curFieldDesc == null && curClassDesc != null) {
>                    curFieldDesc = curClassDesc.getField( curFieldName );
>                    curClassDesc =
(JDOClassDescriptor)curClassDesc.getExtends();
>                  }
                    FieldHandler handler = curFieldDesc.getHandler();
                    curObject = handler.getValue( curObject );
                    curClassDesc = (JDOClassDescriptor)
curFieldDesc.getClassDescriptor();
                }
                catch (Exception ex) {
                    throw new NoSuchElementException( "An exception was
thrown trying to access get methods to follow the path expression. " +
ex.toString() );
                }
            }

            return curObject;
        }

Does this fix look ok?

Stephan Merker

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to