{
// compare the current column defining class and the duplicated column defining class. if the same class,
// we raise an exception when within one class it is defined a column twice
// in some cases it could still be possible to have these duplicated columns, but does not make too
// much sense in most of the cases. (this whole block of duplicated column check, could be optional, like a pmf property)
throw new DuplicateColumnNameException(this.toString(), existingCol, col);
}
// Make sure the field JavaTypeMappings are compatible
if (mapping != null &&
!mapping.getClass().isAssignableFrom(existingCol.getMapping().getClass()) &&
!existingCol.getMapping().getClass().isAssignableFrom(mapping.getClass()))
{
// the mapping class must be the same (not really required, but to avoid user mistakes)
throw new DuplicateColumnNameException(this.toString(), existingCol, col);
}
// Make sure the field java types are compatible
Class fieldStoredJavaTypeClass = null;
Class existingColStoredJavaTypeClass = null;
try
{
ClassLoaderResolver clr = storeMgr.getOMFContext().getClassLoaderResolver(null);
fieldStoredJavaTypeClass = clr.classForName(storedJavaType);
existingColStoredJavaTypeClass = clr.classForName(col.getStoredJavaType());
}
catch (RuntimeException cnfe)
{
// Do nothing
}
if (fieldStoredJavaTypeClass != null && existingColStoredJavaTypeClass != null &&
!fieldStoredJavaTypeClass.isAssignableFrom(existingColStoredJavaTypeClass) &&
!existingColStoredJavaTypeClass.isAssignableFrom(fieldStoredJavaTypeClass))
{
// the stored java type must be the same (not really required, but to avoid user mistakes)
throw new DuplicateColumnNameException(this.toString(), existingCol, col);
}
}
if (!duplicateName)
{