* @param ownerSM State Manager for the set.
* @return Iterator for the set.
*/
public Iterator iterator(ObjectProvider ownerSM)
{
ExecutionContext ec = ownerSM.getExecutionContext();
if (iteratorStmtLocked == null)
{
synchronized (this) // Make sure this completes in case another thread needs the same info
{
// Generate the statement, and statement mapping/parameter information
SQLStatement sqlStmt = getSQLStatementForIterator(ownerSM);
iteratorStmtUnlocked = sqlStmt.getSelectStatement().toSQL();
sqlStmt.addExtension("lock-for-update", true);
iteratorStmtLocked = sqlStmt.getSelectStatement().toSQL();
}
}
Transaction tx = ec.getTransaction();
String stmt = (tx.lockReadObjects() ? iteratorStmtLocked : iteratorStmtUnlocked);
try
{
ManagedConnection mconn = storeMgr.getConnection(ec);
SQLController sqlControl = ((RDBMSStoreManager)storeMgr).getSQLController();