Package org.datanucleus.exceptions

Examples of org.datanucleus.exceptions.NucleusException


            type != JoinType.INNER_JOIN &&
            type != JoinType.LEFT_OUTER_JOIN &&
            type != JoinType.RIGHT_OUTER_JOIN &&
            type != JoinType.CROSS_JOIN)
        {
            throw new NucleusException("Unsupported join type specified : " + type);
        }
        else if (tbl == null)
        {
            throw new NucleusException("Specification of join must supply the table reference");
        }

        this.type = type;
        this.table = tbl;
        this.joinedTable = joinedTbl;
View Full Code Here


    public static Object getValueForPrimaryKeyIndexOfObjectUsingReflection(Object value, int index,
            AbstractClassMetaData cmd, NucleusContext nucleusCtx, ClassLoaderResolver clr)
    {
        if (cmd.getIdentityType() == IdentityType.DATASTORE)
        {
            throw new NucleusException("This method does not support datastore-identity");
        }

        int position = 0;
        int[] pkPositions = cmd.getPKMemberPositions();
        for (int i=0;i<pkPositions.length;i++)
View Full Code Here

                    try
                    {
                        ResultObjectFactory rof = null;
                        if (elementsAreEmbedded || elementsAreSerialised)
                        {
                            throw new NucleusException("Cannot have FK set with non-persistent objects");
                        }
                        else
                        {
                            rof = storeMgr.newResultObjectFactory(emd, iteratorMappingDef, false, null,
                                clr.classForName(elementType));
View Full Code Here

            // First look for "sql-type"
            if (datastoreMappingsBySQLType.get(sqlType.toUpperCase()) == null)
            {
                if (fieldName != null)
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054001",
                        javaType, sqlType, fieldName)).setFatal();
                }
                else
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054000",
                        javaType, sqlType)).setFatal();
                }
            }

            // Find if this sql-type has been defined for this java-type
            Iterator sqlTypeIter = ((Collection) datastoreMappingsBySQLType.get(sqlType.toUpperCase())).iterator();
            while (sqlTypeIter.hasNext())
            {
                RDBMSTypeMapping sqlTypeMapping = (RDBMSTypeMapping)sqlTypeIter.next();
                if (sqlTypeMapping.javaType.equals(javaType))
                {
                    datastoreMapping = sqlTypeMapping;
                    break;
                }
            }
        }
        else if (jdbcType != null)
        {
            // Then look for "jdbc-type"
            if (datastoreMappingsByJDBCType.get(jdbcType.toUpperCase()) == null)
            {
                if (fieldName != null)
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054003",
                        javaType, jdbcType, fieldName)).setFatal();
                }
                else
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054002",
                        javaType, jdbcType)).setFatal();
                }
            }

            // Find if this jdbc-type has been defined for this java-type
            Iterator jdbcTypeIter = ((Collection) datastoreMappingsByJDBCType.get(jdbcType.toUpperCase())).iterator();
            while (jdbcTypeIter.hasNext())
            {
                RDBMSTypeMapping jdbcTypeMapping = (RDBMSTypeMapping)jdbcTypeIter.next();
                if (jdbcTypeMapping.javaType.equals(javaType))
                {
                    datastoreMapping = jdbcTypeMapping;
                    break;
                }
            }
            if (datastoreMapping == null)
            {
                // This JDBC type is supported but not for persisting this java type
                if (fieldName != null)
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054003",
                        javaType, jdbcType, fieldName)).setFatal();
                }
                else
                {
                    throw new NucleusException(LOCALISER_RDBMS.msg("054002",
                        javaType, jdbcType)).setFatal();
                }
            }
        }

        if (datastoreMapping == null)
        {
            // No specified type so get the best for this java-type (if primitve then use the wrapper java-type)
            // Use wrapper type instead of primitive type since primitives have no java-type entries for datastore mappings
            String type = ClassUtils.getWrapperTypeNameForPrimitiveTypeName(javaType);
            Collection mappings = (Collection)datastoreMappingsByJavaType.get(type);
            if (mappings == null)
            {
                // This java-type isnt specifically supported so maybe its superclass is
                Class javaTypeClass = clr.classForName(type);
                Class superClass = javaTypeClass.getSuperclass();
                while (superClass != null && !superClass.getName().equals(ClassNameConstants.Object) && mappings == null)
                {
                    mappings = (Collection) datastoreMappingsByJavaType.get(superClass.getName());
                    superClass = superClass.getSuperclass();
                }
            }
            if (mappings != null)
            {
                if (mappings.size() == 1)
                {
                    datastoreMapping = (RDBMSTypeMapping) mappings.iterator().next();
                }
                else
                {
                    // More than 1 so take the default
                    Iterator mappingsIter = mappings.iterator();
                    while (mappingsIter.hasNext())
                    {
                        RDBMSTypeMapping rdbmsMapping = (RDBMSTypeMapping)mappingsIter.next();
                        if (rdbmsMapping.isDefault())
                        {
                            // default matched so take it
                            datastoreMapping = rdbmsMapping;
                            break;
                        }
                    }

                    // No default set, so use the first one
                    if (datastoreMapping == null && mappings.size() > 0)
                    {
                        datastoreMapping = (RDBMSTypeMapping) mappings.iterator().next();
                    }
                }
            }
        }

        if (datastoreMapping == null)
        {
            if (fieldName != null)
            {
                throw new NucleusException(LOCALISER_RDBMS.msg("054005",
                    javaType, jdbcType, sqlType, fieldName)).setFatal();
            }
            else
            {
                throw new NucleusException(LOCALISER_RDBMS.msg("054004",
                    javaType, jdbcType, sqlType)).setFatal();
            }
        }
        return datastoreMapping.getMappingType();
    }
View Full Code Here

        }
        catch (SQLException sqle)
        {
            String msg = LOCALISER_RDBMS.msg("050052", sqle.getMessage());
            NucleusLogger.DATASTORE.warn(msg, sqle);
            throw new NucleusException(msg, sqle).setFatal();
        }
        finally
        {
            mconn.close();
        }
View Full Code Here

        {
            String msg = LOCALISER.msg(false, "014039");
            NucleusLogger.DATASTORE_SCHEMA.error(msg);
            System.out.println(msg);

            throw new NucleusException(msg);
        }
    }
View Full Code Here

        {
            String msg = LOCALISER.msg(false, "014039");
            NucleusLogger.DATASTORE_SCHEMA.error(msg);
            System.out.println(msg);

            throw new NucleusException(msg);
        }
    }
View Full Code Here

        {
            String msg = LOCALISER.msg(false, "014039");
            NucleusLogger.DATASTORE_SCHEMA.error(msg);
            System.out.println(msg);

            throw new NucleusException(msg);
        }
    }
View Full Code Here

     */
    public SQLExpression getExpression(SQLExpression expr, List args)
    {
        if (!(expr instanceof TemporalExpression))
        {
            throw new NucleusException(LOCALISER.msg("060001", "getYear()", expr));
        }

        RDBMSStoreManager storeMgr = stmt.getRDBMSManager();
        JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(String.class);
        SQLExpression day = exprFactory.newLiteral(stmt, mapping, "year");
View Full Code Here

                this.value = mapValue;
                setStatement();
            }
            else
            {
                throw new NucleusException("Cannot create " + this.getClass().getName() +
                    " for value of type " + (value != null ? value.getClass().getName() : null));
            }
        }
View Full Code Here

TOP

Related Classes of org.datanucleus.exceptions.NucleusException

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.