[OFBiz] Dev - Problem with new OFBiz version

David E. Jones jonesde at ofbiz.org
Fri Apr 8 17:31:29 EDT 2005


Adrian,

I don't really like this fix, here's why:

1. According to the spec we are doing it right, and the Advantage JDBC  
driver is doing it wrong; they should return false and not throw an  
exception when there are no more rows. Here is the JavaDoc for this  
method that clearly explains what is returned:

==============================================
ext
public boolean next()
              throws SQLException
Moves the cursor down one row from its current position.  A ResultSet  
cursor is initially positioned  before the first row; the first call to  
the method  next makes the first row the current row; the  second call  
makes the second row the current row, and so on.

  If an input stream is open for the current row, a call  to the method  
next will  implicitly close it. A ResultSet object's  warning chain is  
cleared when a new row is read.

  Returns:
true if the new current row is valid;  false if there are no more rows
  Throws:
SQLException - if a database access error occurs
==============================================

In general when implementing such specs in Java it is not allowed to  
throw undocumented exceptions. If the fix didn't cause any other  
problems, I'd be fine with it, but this one does because of....

2. Performance impact. The isAfterLast method may not be a big issue  
for some JDBC drivers, but it depends on how they are implemented and I  
know that in some cases this can require round-trips to the database  
and such, which is a huge performance impact. That's why we call next  
over and over instead of hasNext, even though that is implemented  
because the EntityListIterator implements the ListIterator interface.

Does that make sense? This should be a bug report to Advantage, not to  
OFBiz. I know it is usually easier to get something fixed in an open  
source project than a closed source commercial application, and it's  
flattering that you would try to resolve the issue in this way.

But, for the sake of just about everyone else who is using OFBiz, my  
decision must be to decline this change. Of course, it is open to  
discussion and I'd be happy to consider what you or anyone else has to  
say.

-David


On Apr 7, 2005, at 3:46 PM, Adrian Crum wrote:

> The latest OFBiz version generates this error:
>
> java.lang.Thread.run(Unknown Source)
> org.ofbiz.base.util.GeneralRuntimeException: Error getting the next  
> result ([Extended Systems][Advantage JDBC]Result set is after last  
> row.)
> org.ofbiz.entity.util.EntityListIterator.next(EntityListIterator.java: 
> 308)
> org.ofbiz.widget.form.ModelForm.safeNext(ModelForm.java:972)
>
> It looks like the ResultSet next() method is being called after it's  
> past the last row.
>
> I made this patch to EntityListIterator to get it to work:
>
>     public Object next() {
>         try {
>             if (!resultSet.isAfterLast() && resultSet.next()) {
>                 return currentGenericValue();
>             } else {
>                 return null;
>             }
>         } catch (SQLException e) {
>
>
> _______________________________________________
> Dev mailing list
> Dev at lists.ofbiz.org
> http://lists.ofbiz.org/mailman/listinfo/dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2363 bytes
Desc: not available
Url : http://lists.ofbiz.org/pipermail/dev/attachments/20050408/cc981484/smime.bin


More information about the Dev mailing list