try
{
ChromatticSession session = persister.getSession();
// retrieve the mapping associated with the persistence key and if it exists, reset it to the data of the specified ProducerInfo
ProducerInfoMapping pim = session.findById(ProducerInfoMapping.class, key);
if (pim == null)
{
throw new IllegalArgumentException("Couldn't find ProducerInfoMapping associated with key " + key);
}
oldId = pim.getId();
newId = producerInfo.getId();
pim.initFrom(producerInfo);
idUnchanged = oldId.equals(newId);
// if the ProducerInfo's last modified date is posterior to the set it's contained in, modify that one too
ProducerInfosMapping pims = getProducerInfosMapping(session);
final long pimsLastModified = pims.getLastModified();
final long lastModified = producerInfo.getLastModified();
if (lastModified > pimsLastModified)
{
pims.setLastModified(lastModified);
}
if (!idUnchanged)
{
// the consumer was renamed, we need to update its parent
Map<String, ProducerInfoMapping> nameToProducerInfoMap = pims.getNameToProducerInfoMap();
nameToProducerInfoMap.put(pim.getId(), pim);
}
persister.save();
// if the consumer's id has changed, return the old one so that state can be updated