Author: sichen
Date: Wed Jun 11 10:46:47 2008
New Revision: 666746
URL:
http://svn.apache.org/viewvc?rev=666746&view=revLog:
ofbiz 1826: allow EntityListIterator to be created from jdbc ResultSet
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java?rev=666746&r1=666745&r2=666746&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java Wed Jun 11 10:46:47 2008
@@ -67,6 +67,14 @@
this.modelFieldTypeReader = modelFieldTypeReader;
}
+ public EntityListIterator(ResultSet resultSet, ModelEntity modelEntity, List selectFields, ModelFieldTypeReader modelFieldTypeReader) {
+ this.sqlp = null;
+ this.resultSet = resultSet;
+ this.modelEntity = modelEntity;
+ this.selectFields = selectFields;
+ this.modelFieldTypeReader = modelFieldTypeReader;
+ }
+
public void setDelegator(GenericDelegator delegator) {
this.delegator = delegator;
}
@@ -128,8 +136,19 @@
//maybe not the best way: throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed");
Debug.logWarning("This EntityListIterator for Entity [" + modelEntity==null?"":modelEntity.getEntityName() + "] has already been closed, not closing again.", module);
} else {
- sqlp.close();
- closed = true;
+ if (sqlp != null) {
+ sqlp.close();
+ closed = true;
+ } else if (resultSet != null) {
+ try {
+ resultSet.close();
+ } catch (SQLException e) {
+ throw new GenericEntityException("Cannot close EntityListIterator with ResultSet", e);
+ }
+ closed = true;
+ } else {
+ throw new GenericEntityException("Cannot close an EntityListIterator without a SQLProcessor or a ResultSet");
+ }
}
}