Package org.jpox.exceptions

Examples of org.jpox.exceptions.JPOXException


                      {
                          return seekingClass.getDeclaredField(fieldName);
                      }
                      catch (SecurityException ex)
                      {
                          throw new JPOXException("CannotGetDeclaredField",ex).setFatal();
                      }
                      catch (NoSuchFieldException ex)
                      {
                          // do nothing, we will return null later if no
                          // field is found in this class or superclasses
                      }
                      catch (LinkageError ex)
                      {
                          throw new JPOXException("ClassLoadingError",ex).setFatal();
                      }
                      seekingClass = seekingClass.getSuperclass();
                    } while(seekingClass != null);

                    //no field found
View Full Code Here


                            }
                        });
                }
                catch (SecurityException ex)
                {
                    throw new JPOXException("Cannot access field: " + fieldName,ex).setFatal();
                }
            }
            fieldValue = field.get(object);
        }
        catch (IllegalArgumentException e2)
View Full Code Here

            case COMPILE_EXPLICIT_VARIABLES :
                compileExplicitVariables();
                return null;

            default :
                throw new JPOXException("Query Compiler doesnt support compilation of type " + type);
        }
    }
View Full Code Here

            {
                obj = ctr.newInstance(args);
            }
            catch (InvocationTargetException e)
            {
                throw new JPOXException(LOCALISER.msg("041009", mappingClass.getName(),
                    e.getTargetException()), e.getTargetException()).setFatal();
            }
            catch (Exception e)
            {
                throw new JPOXException(LOCALISER.msg("041009", mappingClass.getName(), e), e).setFatal();
            }
        }
        catch (NoSuchMethodException nsme)
        {
            throw new JPOXException(LOCALISER.msg("041007", JavaTypeMapping.class, MappedStoreManager.class,
                DatastoreField.class, mappingClass.getName())).setFatal();
        }
        return (DatastoreMapping) obj;
    }
View Full Code Here

        {
          mapping = (JavaTypeMapping)mappingClass.newInstance();
        }
        catch (Exception e)
        {
            throw new JPOXException(LOCALISER.msg("041009", mappingClass.getName(), e), e).setFatal();
        }
        mapping.initialize(dba, type);
        return mapping;
    }
View Full Code Here

        {
          mapping = (JavaTypeMapping)mappingClass.newInstance();
        }
        catch (Exception e)
        {
            throw new JPOXException(LOCALISER.msg("041009", mappingClass.getName(), e), e).setFatal();
        }

        if (roleForField >= 0)
        {
            mapping.setRoleForField(roleForField);
View Full Code Here

        // Create the mapping of the selected type
        JavaTypeMapping m = MappingFactory.createMapping(mc, dba, fmd, roleForField, datastoreContainer, clr);
        if (m == null)
        {
            throw new JPOXException(LOCALISER.msg("041011", mc.getName())).setFatal();
        }

        return m;
    }
View Full Code Here

            ClassLoaderResolver clr)
    {
        if (!fmd.hasCollection() && !fmd.hasArray())
        {
            // TODO Localise this message
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
                " that has no collection/array!").setFatal();
        }
        if (fmd.getJoinMetaData() == null)
        {
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
                " that has no join table defined for the collection/array").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getElementMetaData() != null)
        {
            userMappingClassName = fmd.getElementMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this element so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = ((fmd.hasCollection() && fmd.getCollection().isSerializedElement()) ||
            (fmd.hasArray() && fmd.getArray().isSerializedElement()));
        boolean embeddedPC = (fmd.getElementMetaData() != null && fmd.getElementMetaData().getEmbeddedMetaData() != null);
        boolean elementPC = ((fmd.hasCollection() && fmd.getCollection().getElementClassMetaData() != null) ||
            (fmd.hasArray() && fmd.getArray().getElementClassMetaData() != null));
        boolean embedded = true;
        if (fmd.hasCollection())
        {
            embedded = fmd.getCollection().isEmbeddedElement();
        }
        else if (fmd.hasArray())
        {
            embedded = fmd.getArray().isEmbeddedElement();
        }

        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class elementCls = null;
        if (fmd.hasCollection())
        {
            elementCls = clr.classForName(fmd.getCollection().getElementType());
        }
        else if (fmd.hasArray())
        {
            elementCls = clr.classForName(fmd.getArray().getElementType());
        }
        boolean elementReference = typeMgr.isReferenceType(elementCls);

        Class mc = null;
        if (serialised)
        {
            if (elementPC)
            {
                // Serialised PC element
                mc = SerialisedElementPCMapping.class;
            }
            else if (elementReference)
            {
                // Serialised Reference element
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC type
                mc = EmbeddedElementPCMapping.class;
            }
            else if (elementPC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(elementCls, serialised, embedded, fmd.getFullFieldName(),
                    typeMgr, container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other element mappings
            throw new JPOXException("Attempt to get element mapping for field " + fmd.getFullFieldName() +
            " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }
View Full Code Here

            DatastoreAdapter dba,
            ClassLoaderResolver clr)
    {
        if (fmd.getMap() == null)
        {
            throw new JPOXException("Attempt to get key mapping for field that has no map!").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getKeyMetaData() != null)
        {
            userMappingClassName = fmd.getKeyMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this key so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = (fmd.hasMap() && fmd.getMap().isSerializedKey());
        boolean embedded = (fmd.hasMap() && fmd.getMap().isEmbeddedKey());
        boolean embeddedPC = (fmd.getKeyMetaData() != null && fmd.getKeyMetaData().getEmbeddedMetaData() != null);
        boolean keyPC = (fmd.hasMap() && fmd.getMap().getKeyClassMetaData() != null);
        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class keyCls = clr.classForName(fmd.getMap().getKeyType());
        boolean keyReference = typeMgr.isReferenceType(keyCls);

        Class mc = null;
        if (serialised)
        {
            if (keyPC)
            {
                // Serialised PC key
                mc = SerialisedKeyPCMapping.class;
            }
            else if (keyReference)
            {
                // Serialised Reference key
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC key
                mc = EmbeddedKeyPCMapping.class;
            }
            else if (keyPC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(keyCls, serialised, embedded, fmd.getFullFieldName(), typeMgr,
                    container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other key mappings
            throw new JPOXException("Attempt to get key mapping for field " + fmd.getFullFieldName() +
                " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }
View Full Code Here

            DatastoreAdapter dba,
            ClassLoaderResolver clr)
    {
        if (fmd.getMap() == null)
        {
            throw new JPOXException("Attempt to get value mapping for field that has no map!").setFatal();
        }

        String userMappingClassName = null;
        if (fmd.getValueMetaData() != null)
        {
            userMappingClassName = fmd.getValueMetaData().getValueForExtension("mapping-class");
        }
        if (userMappingClassName != null)
        {
            // User has defined their own mapping class for this value so use that
            try
            {
                return clr.classForName(userMappingClassName);
            }
            catch (JPOXException jpe)
            {
                throw new JPOXUserException(LOCALISER.msg("041014", userMappingClassName)).setFatal();
            }
        }

        boolean serialised = (fmd.hasMap() && fmd.getMap().isSerializedValue());
        boolean embedded = (fmd.hasMap() && fmd.getMap().isEmbeddedValue());
        boolean embeddedPC = (fmd.getValueMetaData() != null && fmd.getValueMetaData().getEmbeddedMetaData() != null);
        boolean valuePC = (fmd.hasMap() && fmd.getMap().getValueClassMetaData() != null);
        TypeManager typeMgr = fmd.getMetaDataManager().getOMFContext().getTypeManager();
        Class valueCls = clr.classForName(fmd.getMap().getValueType());
        boolean valueReference = typeMgr.isReferenceType(valueCls);

        Class mc = null;
        if (serialised)
        {
            if (valuePC)
            {
                // Serialised PC value
                mc = SerialisedValuePCMapping.class;
            }
            else if (valueReference)
            {
                // Serialised Reference value
                mc = SerialisedReferenceMapping.class;
            }
            else
            {
                // Serialised Non-PC element
                mc = SerialisedMapping.class;
            }
        }
        else if (embedded)
        {
            if (embeddedPC)
            {
                // Embedded PC key
                mc = EmbeddedValuePCMapping.class;
            }
            else if (valuePC)
            {
                // "Embedded" PC type but no <embedded> so dont embed for now. Is this correct?
                mc = PersistenceCapableMapping.class;
            }
            else
            {
                // Embedded Non-PC type
                mc = getMappingClass(valueCls, serialised, embedded, fmd.getFullFieldName(), typeMgr,
                    container.getStoreManager().getApiAdapter());
            }
        }
        else
        {
            // TODO Allow for other value mappings
            throw new JPOXException("Attempt to get value mapping for field " + fmd.getFullFieldName() +
                " when not embedded or serialised - please report this to JPOX developers").setFatal();
        }

        return mc;
    }
View Full Code Here

TOP

Related Classes of org.jpox.exceptions.JPOXException

Copyright © 2018 www.massapicom. 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.