Thanks Geert!

On Sun, May 4, 2008 at 4:10 PM, Geert Bevin <[EMAIL PROTECTED]> wrote:

>
> Oooh, you shouldn't loop over the result set in the row processor,
> that is exactly what executeFetchAll will do.
>
> Remove this loop statement:
>
> while (rs.next())
>
> Then everything should be fine.
>
> On 5/4/08, Kerwin Mark Gordo <[EMAIL PROTECTED]> wrote:
> > Hi Geert,
> >
> > Thanks for responding.
> >
> > Here is the code snippet:
> >
> > definitions: dbm is DbQueryManager object
> >                  p is a Product object which needs to be set with its
> > "dynamic" properties
> >                  ds is the Datasource object
> >
> >
> > Select select = new
> > Select(ds).field("*").from("productpropertydata as ppd,
> > propertytype as pt")
> >
> > .where("ppd.productID","=",productID)
> >                                 .whereAnd("ppd.propertyID = pt.id");
> >
> >
> >  PropertyRowProcessor rp = new PropertyRowProcessor();
> >
> >  if (dbm.executeFetchAll(select,rp)){
> >          for (Property prop: rp.properties){
> >                 p.setProperty(prop);
> >           }
> >   }
> >
> >
> > // definition of PropertyRowProcessor
> > class PropertyRowProcessor extends DbRowProcessor {
> >     public ArrayList<Property> properties = new ArrayList<Property>();
> >
> >     public boolean processRow(ResultSet rs) throws SQLException {
> >         try {
> >             while (rs.next()){
> >                 PropertyType pType = new PropertyType();
> >                 ....
> >
> >
> >                 Property property = new Property(pType);
> >                 property.setName(name);
> >                 property.setValue(rs.getString("value"));
> >
> >                 properties.add(property);
> >             }
> >             return true;
> >         } catch (SQLException e){
> >             return false;
> >         }
> >     }
> > }
> >
> >
> > I pasted the sql query string of the Select object select into
> phpmyadmin
> > tool and it returned 2 rows which is what I expect. When I debugged the
> code
> > above and stepped line by line inside the while(rs.next()) loop of
> > PropertyRowProcessor it only looped once. I looked
> > into the resultset object and I don't pretty much understand its
> internals.
> >
> > After many failed trials I tried to do the "traditional" way of querying
> the
> > database and used the following code:
> >
> >     Select select = new
> > Select(ds).field("*").from("productpropertydata as ppd,
> > propertytype as pt")
> >
> > .where("ppd.productID","=",productID)
> >                                    .whereAnd("ppd.propertyID = pt.id");
> >
> >
> >      PropertyRowProcessor rp = new PropertyRowProcessor();
> >
> >       DbStatement dbst =
> > ds.getConnection().createStatement();
> >       dbst.executeQuery(select);
> >       rp.processRow(dbst.getResultSet());
> >       for (Property prop: rp.properties){
> >              p.setProperty(prop);
> >       }
> >
> > Alas this code worked! the resultset object passed to the processRow
> > function looped twice!
> >
> > Thanks, I hope that you could clarify on this matter.
> >
> > Kerwin
> >
> >
> >
> > On Thu, May 1, 2008 at 5:54 PM, Geert Bevin <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi Kerwin,
> > >
> > > Very weird, I didn't get this message through email.
> > >
> > > Could you please paste the code that you're using. My initial thought
> > > would be that you return false from with the DbRowProcessor, this
> > > interrupt the retrieval. I can say you that that in the tenths of
> > > applications that I have written, executeFetchAll has always worked
> > > correctly and the unit tests assert it too. You might have stumbled
> > > into an edge case where it doesn't, but in that case I need more
> > > information to be able to track it down and reproduce it.
> > >
> > > HTH,
> > >
> > > Geert
> > >
> > >
> > >
> > >
> > > On Apr 26, 11:06 am, Kerwin <[EMAIL PROTECTED]> wrote:
> > > > Hi All,
> > > >
> > > > I'm new to RIFE and lately I've been trying to use DbQueryManager
> > > > class specifically executeFetchAll function. The problem is when I
> > > > iterate through the ResultSet object passed to a subclass of
> > > > DbRowProcessor it only loops once when I expected it will loop
> twice.
> > > >
> > > > I'm confused because if I use the traditional jdbc way of getting
> the
> > > > ResultSet object using the same query and using DbConnection,
> > > > DbStatement and DbResultSet classes I get the correct no. of rows I
> > > > expect and loops twice through DbResultSet.
> > > >
> > > > Thanks
> > > > Kerwin
> > >
> > >
> >
> >
> > >
> >
>
>
> --
> Geert Bevin
> Terracotta - http://www.terracotta.org
> Uwyn "Use what you need" - http://uwyn.com
> RIFE Java application framework - http://rifers.org
> Music and words - http://gbevin.com
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"rife-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to