hi alan,

thanks for the fix. it's in cvs now.
btw have you found a way to do an insert with only one sql ??

jakob

----- Original Message -----
From: "Olmanson, Alan" <[EMAIL PROTECTED]>
To: "'OJB Users List'" <[EMAIL PROTECTED]>
Sent: Friday, December 20, 2002 8:55 PM
Subject: RE: Bug / coding oversight?


> Jakob,
>
> Sorry that didn't work for me.  The problem is that my Sql criteria
contains
> a '.' which is throwing off the pathElement.  I made a few changes below
> that make it work for me.
>
> Alan
>
> ---------------------------
>     private OJBIterator getRsIteratorFromQueryExtentAware(Query query,
>                                                           ClassDescriptor
> cld,
>
RsIteratorFactory
> factory)
>     {
>         if (logger.isDebugEnabled())
>         {
>             logger.debug("-> Looking for objects of type [" +
> cld.getClassNameOfObject()+"]");
>         }
>
>         /*
>          * PRE CONDITIONS
>          */
>
>         /* We must use a criteria object */
>         if(!(query instanceof QueryByCriteria))
>         {
>             return getRsIteratorFromQuery(query,cld,factory);
>         }
>
>         Criteria criteria = query.getCriteria();
>         if(criteria == null)
>         {
>             return getRsIteratorFromQuery(query,cld,factory);
>         }
>
>         Enumeration enum = criteria.getElements();
>         if(enum == null)
>         {
>             return getRsIteratorFromQuery(query,cld,factory);
>         }
>
>         /*
>          * Ok, we have some criteria elements to traverse
>          */
>         ChainingIterator chainingIterator = new ChainingIterator();
>         boolean pathElementPresent = false;
>         HashSet processedClasses = new HashSet();
>
>         while(enum.hasMoreElements())
>         {
>             Object criteriaElement = enum.nextElement();
>             logger.debug("  --# Criteria element ["+criteriaElement+"]
class
> "+criteriaElement.getClass().getName());
>             if (criteriaElement instanceof Criteria)
>             {
>                 // TODO : nested criteria
>                 //logger.debug("  --# Nested Criteria
> ["+criteriaElement+"]");
>                 continue;
>             }
>
>             SelectionCriteria selectionCriteria =
> (SelectionCriteria)criteriaElement;
>             String attribute = selectionCriteria.getAttribute();
>             int dotPos = attribute.lastIndexOf(".");
>
>             if(dotPos >= 0)
>             {
>                 //We are dealing with a path expression, include iterators
> for all concrete subclasses
>
>                 String pathElement =
> ClassDescriptor.cleanPath(attribute).substring(0,dotPos);
>                 logger.debug("  --# Looking for concrete classes on
> pathElement ["+pathElement+"]");
>
>                 //TODO revise this cast
>                 Class hintClass =
> ((QueryByCriteria)query).getClassForPath(pathElement);
>                 if(hintClass != null)
>                 {
>                     // BRJ: do the same class only once
>                     if(processedClasses.contains(hintClass))
>                     {
>                         continue;
>                     }
>                     processedClasses.add(hintClass);
>
>                     //preserve user supplied hint
>                     pathElementPresent = true;
>
> chainingIterator.addIterator(getRsIteratorFromQuery(query,cld,factory));
>                 }
>                 else
>                 {
>                     List concreteClasses =
> getClassObjectsForPathElement(cld,pathElement);
>                     if(concreteClasses == null)
>                     {
>                         throw new NullPointerException("Path element
> ["+pathElement+"] refers abstract classes only");
>                     }
>
>                     if (concreteClasses.size() > 0) {
>                         // BRJ: do the same class only once
>                         pathElementPresent = true;
>
> if(processedClasses.contains(concreteClasses.get(0)))
>                         {
>                             continue;
>                         }
>                         processedClasses.add(concreteClasses.get(0));
>
>                         Iterator it = concreteClasses.iterator();
>                         while(it.hasNext())
>                         {
>                             Class extentClass = (Class)it.next();
>                             logger.debug("  --# Modifying Query to include
> class ["+extentClass.getName()+"] for path element ["+pathElement+"]");
>
> ((QueryByCriteria)query).addPathClass(pathElement,extentClass);
>
>
> chainingIterator.addIterator(getRsIteratorFromQuery(query,cld,factory));
>                         }
>                     }
>                 }
>             }
>         }
>
>         if(pathElementPresent)
>         {
>             return chainingIterator;
>         }
>         else
>         {
>             return getRsIteratorFromQuery(query,cld,factory);
>         }
>     }
> ---------------------------
>
>
> -----Original Message-----
> From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 20, 2002 12:57 PM
> To: OJB Users List
> Subject: Re: Bug / coding oversight?
>
>
> hi alan,
>
> i just checked in a new revision of PersistenceBrokerImpl with fixes in
> getRsIteratorExtentAware().
> please have a look at it.
> this fix does NOT contain your modification to satisfy referential
> integrity.
>
> jakob
>
> ----- Original Message -----
> From: "Jakob Braeuchi" <[EMAIL PROTECTED]>
> To: "OJB Users List" <[EMAIL PROTECTED]>
> Sent: Friday, December 20, 2002 5:56 PM
> Subject: Re: Bug / coding oversight?
>
>
> > hi alan,
> >
> > when adding your if(chainingIterator==null), i get all my objects twice.
> the
> > problem is imo the implementation of the extentaware iterator. for each
> > criteria containing a path it adds an iterator (resulting in a query!).
> >
> > in my testcase i have a query with two criteria containing path
> expressions,
> > so two queries are executed and two iterators are added to the chaining
> > iterator. the result is the above mentioned double number of objects.
> >
> > jakob
> >
> >
> > ----- Original Message -----
> > From: "Olmanson, Alan" <[EMAIL PROTECTED]>
> > To: "OJB Users List" <[EMAIL PROTECTED]>
> > Sent: Friday, December 20, 2002 1:03 AM
> > Subject: Bug / coding oversight?
> >
> >
> > > Hello,
> > >
> > > I think I've run across a bug (more likely a coding oversight).
> > >
> > > In the PersistenceBrokerImpl in the method
> > > getRsIteratorFromQueryExtentAware(Query, ClassDescriptor,
> > > RsIteratorFactory);
> > >
> > > Before the while(enum.hasMoreElements()) loop a chainingIterator is
> > defined
> > > and set to null.
> > >
> > > With in the loop the chainingIterator is created.
> > >
> > > The problem is it's recreated on each iteration of the loop.
Shouldn't
> it
> > > only be created if it is null?
> > >
> > > I had two criteriaElements added in my Criteria the first was a
NotNull
> > the
> > > other an SQL. I was getting nothing returned until I added:
> > >
> > >     if (chainingIterator == null) {
> > >         chainingIterator = new ChainingIterator();
> > >     }
> > >
> > > Alan
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>


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

Reply via email to