throw new EJBException("Internal error setting instance field " + getFieldName(), e);
}
}
public void setValueInternal(CmpEntityBeanContext ctx, Object value, boolean makeDirty) {
PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext();
// todo this is weird
if (cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember) {
Object curValue = pctx.getFieldValue(rowIndex);
if (value != null && !value.equals(curValue)) {
throw new IllegalStateException(
"Attempt to modify a primary key field through a foreign key field mapped to it: "
+
entity.getEntityName()
+ "."
+ cmpFieldIAmMappedTo.getFieldName()
+
" -> "
+ entity.getQualifiedTableName()
+ "."
+ cmpFieldIAmMappedTo.getColumnName() +
", current value=" + curValue + ", new value=" + value
);
}
makeDirty = false;
} else {
pctx.setFieldValue(rowIndex, value);
}
if (makeDirty) {
pctx.setDirty();
}
}