if (trace)
{
log.trace("Inserted " + rows + " rows");
}
Message m = pair.ref.getMessage();
synchronized (m)
{
if (!m.isPersisted())
{
if (psInsertMessage == null)
{
psInsertMessage = conn
.prepareStatement(getSQLStatement("INSERT_MESSAGE"));
}
storeMessage(m, psInsertMessage, true);
rows = psInsertMessage.executeUpdate();
if (trace)
{
log.trace("Inserted " + rows + " rows");
}
m.setPersisted(true);
messagesStored.add(m);
}
}
}
// Now the removes
iter = refsToRemove.iterator();
while (iter.hasNext())
{
if (psUpdateReference == null)
{
psUpdateReference = conn
.prepareStatement(getSQLStatement("UPDATE_MESSAGE_REF"));
}
ChannelRefPair pair = (ChannelRefPair) iter.next();
prepareToRemoveReference(pair.channelID, pair.ref, tx,
psUpdateReference);
int rows = psUpdateReference.executeUpdate();
if (trace)
{
log.trace("updated " + rows + " rows");
}
}
return null;
}
catch (Exception e)
{
for (Iterator i = messagesStored.iterator(); i.hasNext();)
{
Message msg = (Message) i.next();
msg.setPersisted(false);
}
throw e;
}
finally
{