Fix passing parameters LIMIT and OFFSET to sql query in the method getItems() for oracle

This commit is contained in:
Ivo Prajer
2015-03-14 14:36:51 +01:00
parent 54ee54ba4d
commit 6815e25dbe

View File

@@ -28,6 +28,7 @@ import org.dspace.workflow.WorkflowItem;
import org.dspace.xmlworkflow.storedcomponents.CollectionRole; import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem; import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
import java.io.Serializable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@@ -450,13 +451,20 @@ public class Collection extends DSpaceObject
*/ */
public ItemIterator getItems(Integer limit, Integer offset) throws SQLException public ItemIterator getItems(Integer limit, Integer offset) throws SQLException
{ {
String myQuery = "SELECT item.* FROM item, collection2item WHERE " List<Serializable> params = new ArrayList<Serializable>();
+ "item.item_id=collection2item.item_id AND " StringBuffer myQuery = new StringBuffer(
+ "collection2item.collection_id= ? " "SELECT item.* " +
+ "AND item.in_archive='1' limit ? offset ?"; "FROM item, collection2item " +
"WHERE item.item_id = collection2item.item_id " +
"AND collection2item.collection_id = ? " +
"AND item.in_archive = '1'"
);
TableRowIterator rows = DatabaseManager.queryTable(ourContext, "item", params.add(getID());
myQuery,getID(), limit, offset); DatabaseManager.applyOffsetAndLimit(myQuery, params, offset, limit);
TableRowIterator rows = DatabaseManager.query(ourContext,
myQuery.toString(), params.toArray());
return new ItemIterator(ourContext, rows); return new ItemIterator(ourContext, rows);
} }