*/
public void setValue(int nOrdinal, Object value)
{
assert !isLazy();
Attribute attribute = m_metaclass.getInstanceAttribute(nOrdinal);
value = convert(attribute, value);
Object oldValue = getValueDirect(nOrdinal);
if (!ObjUtil.equal(oldValue, value))
{
if (!isLoading())
{
checkUpdateAccess(attribute);
if (oldValue == Undefined.VALUE && attribute.isReverseInverseDependencyPersistent())
{
oldValue = getValue(nOrdinal);
}
if (m_nState == DIRTY || m_nState == NEW)
{
if (m_uow != m_context.getUnitOfWork() && m_context.isUnitOfWorkGlobal())
{
throw new TransactionException("err.runtime.wrongTransaction",
new Object[]{getLazyClassName()});
}
if (!isEventPending())
{
m_context.getUnitOfWork().addChange(this);
}
setEventPending(true);
}
else
{
setDirty();
}
if (attribute.isCalculated())
{
setOverridden(nOrdinal);
}
attribute.invalidateDependency(this, Invalid.VALUE);
}
if (attribute.isCollection())
{
if (attribute.getType().isPrimitive())
{
setValueDirect(nOrdinal, (List)value);
}
else
{
InstanceList list = (InstanceList)value;
if (list != null && !isLoading())
{
list.checkUpdateAccess(attribute.getReverse(), this);
}
setValueDirect(nOrdinal, list);
if (list != null)
{
list.setAssociation(this, attribute, isLoading());
setAliases(list);
}
}
}
else
{
Attribute reverse = attribute.getReverse();
if (reverse != null)
{
int nRevOrdinal = reverse.getOrdinal();
if (oldValue instanceof Instance && attribute.isReverseOf(reverse))
{
Instance instance = (Instance)oldValue;