boolean changesPrimary = baseFieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY, false) !=
keyDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_PRIMARYKEY, false) ;
if (isIgnored || changesJdbcType || changesPrimary)
{
FeatureDescriptorDef usingFeature = null;
do
{
usingFeature = usedByReference(modelDef, baseFieldDef);
if (usingFeature != null)
{
if (isIgnored)
{
throw new ConstraintException("Cannot ignore field "+keyDef.getName()+" in class "+keyDef.getOwner().getName()+
" because it is used in class "+baseFieldDef.getOwner().getName()+
" by the reference "+usingFeature.getName()+" from class "+
usingFeature.getOwner().getName());
}
else if (changesJdbcType)
{
throw new ConstraintException("Modification of the jdbc-type for the field "+keyDef.getName()+" in class "+
keyDef.getOwner().getName()+" is not allowed because it is used in class "+
baseFieldDef.getOwner().getName()+" by the reference "+usingFeature.getName()+
" from class "+usingFeature.getOwner().getName());
}
else
{
throw new ConstraintException("Cannot change the primarykey status of field "+keyDef.getName()+" in class "+
keyDef.getOwner().getName()+" as primarykeys are used in class "+
baseFieldDef.getOwner().getName()+" by the reference "+usingFeature.getName()+
" from class "+usingFeature.getOwner().getName());
}
}
usingFeature = usedByCollection(modelDef, baseFieldDef, changesPrimary);
if (usingFeature != null)
{
if (isIgnored)
{
throw new ConstraintException("Cannot ignore field "+keyDef.getName()+" in class "+keyDef.getOwner().getName()+
" because it is used in class "+baseFieldDef.getOwner().getName()+
" as a foreignkey of the collection "+usingFeature.getName()+" from class "+
usingFeature.getOwner().getName());
}
else if (changesJdbcType)
{
throw new ConstraintException("Modification of the jdbc-type for the field "+keyDef.getName()+" in class "+
keyDef.getOwner().getName()+" is not allowed because it is used in class "+
baseFieldDef.getOwner().getName()+" as a foreignkey of the collecton "+
usingFeature.getName()+" from class "+usingFeature.getOwner().getName());
}
else
{
throw new ConstraintException("Cannot change the primarykey status of field "+keyDef.getName()+" in class "+
keyDef.getOwner().getName()+" as primarykeys are used in class "+
baseFieldDef.getOwner().getName()+" by the collection "+usingFeature.getName()+
" from class "+usingFeature.getOwner().getName());
}
}
baseFieldDef = (FieldDescriptorDef)baseFieldDef.getOriginal();
}