Examples of DuplicateDatastoreFieldException


Examples of org.datanucleus.store.mapped.exceptions.DuplicateDatastoreFieldException

                {
                    // 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 DuplicateDatastoreFieldException(this.toString(), existingCol, col);
                }

                // Make sure the field JavaTypeMappings are compatible
                if (mapping != null &&
                        !mapping.getClass().isAssignableFrom(existingCol.getJavaTypeMapping().getClass()) &&
                        !existingCol.getJavaTypeMapping().getClass().isAssignableFrom(mapping.getClass()))
                {
                    // the mapping class must be the same (not really required, but to avoid user mistakes)
                    throw new DuplicateDatastoreFieldException(this.toString(), existingCol, col);
                }
            }
            else
            {
                if (mapping != null && mapping.getMemberMetaData() != null)
                {
                    NucleusLogger.DATASTORE_SCHEMA.warn("Column " + existingCol +
                        " has already been defined but needing to reuse it for " + mapping.getMemberMetaData().getFullFieldName());
                }
                else
                {
                    NucleusLogger.DATASTORE_SCHEMA.warn("Column " + existingCol +
                        " has already been defined but needing to reuse it");
                }
            }

            // Make sure the field java types are compatible
            Class fieldStoredJavaTypeClass = null;
            Class existingColStoredJavaTypeClass = null;
            try
            {
                ClassLoaderResolver clr = storeMgr.getNucleusContext().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 DuplicateDatastoreFieldException(this.toString(), existingCol, col);
            }
        }

        if (!duplicateName)
        {
View Full Code Here

Examples of org.datanucleus.store.mapped.exceptions.DuplicateDatastoreFieldException

        ((AbstractClassMetaData) dupMd).getFullClassName())) {
      // 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 DuplicateDatastoreFieldException(this.toString(), existingCol, col);
    }

    // Make sure the field JavaTypeMappings are compatible
    if (mapping != null &&
        !mapping.getClass().isAssignableFrom(existingCol.getJavaTypeMapping().getClass()) &&
        !existingCol.getJavaTypeMapping().getClass().isAssignableFrom(mapping.getClass())) {
      // the mapping class must be the same (not really required, but to avoid user mistakes)
      throw new DuplicateDatastoreFieldException(this.toString(), existingCol, col);
    }

    // Make sure the field java types are compatible
    Class<?> fieldStoredJavaTypeClass = null;
    Class<?> existingColStoredJavaTypeClass = null;
    try {
      ClassLoaderResolver clr = storeMgr.getNucleusContext().getClassLoaderResolver(null);
      fieldStoredJavaTypeClass = clr.classForName(col.getStoredJavaType());
      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 DuplicateDatastoreFieldException(this.toString(), existingCol, col);
    }
    return true;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.