Package org.datanucleus.exceptions

Examples of org.datanucleus.exceptions.NucleusUserException


                                // Class doesn't have its own table (subclass-table) so find where it persists
                                AbstractClassMetaData[] ownerParentCmds =
                                    storeMgr.getClassesManagingTableForClass(relatedCmd, clr);
                                if (ownerParentCmds.length > 1)
                                {
                                    throw new NucleusUserException("Relation (" + mmd.getFullFieldName() +
                                    ") with multiple related tables (using subclass-table). Not supported");
                                }

                                relatedTbl = storeMgr.getDatastoreClass(ownerParentCmds[0].getFullClassName(), clr);
                            }
View Full Code Here


                {
                    discriminatorValue = Integer.valueOf(strValue);
                }
                catch (NumberFormatException nfe)
                {
                    throw new NucleusUserException("Discriminator for " + className + " is not integer-based but needs to be!");
                }
            }
            else
            {
                discriminatorValue = targetCmd.getInheritanceMetaData().getDiscriminatorMetaData().getValue();
View Full Code Here

                {
                    Class.forName(driverName).newInstance();
                }
                catch (Exception e2)
                {
                    throw new NucleusUserException(LOCALISER.msg("047006", driverName), e).setFatal();
                }
            }
        }
    }
View Full Code Here

    throws SQLException
    {
        if (StringUtils.isWhitespace(driverName))
        {
            // User didnt bother specifying the JDBC driver
            throw new NucleusUserException(LOCALISER.msg("047007"));
        }

        return getConnection(this.userName, this.password);
    }
View Full Code Here

                //try with DriverManager for known drivers
                return DriverManager.getConnection(url, this.userName, this.password);
            }
            catch (Exception e2)
            {
                throw new NucleusUserException(LOCALISER.msg("047006", driverName), e).setFatal();
            }
        }
    }
View Full Code Here

        String rsTypeString = RDBMSQueryUtils.getResultSetTypeForQuery(query);
        if (rsTypeString != null &&
            (!rsTypeString.equals("scroll-sensitive") && !rsTypeString.equals("forward-only") &&
             !rsTypeString.equals("scroll-insensitive")))
        {
            throw new NucleusUserException(LOCALISER.msg("052510"));
        }

        String rsConcurrencyString = RDBMSQueryUtils.getResultSetConcurrencyForQuery(query);
        if (rsConcurrencyString != null &&
            (!rsConcurrencyString.equals("read-only") && !rsConcurrencyString.equals("updateable")))
        {
            throw new NucleusUserException(LOCALISER.msg("052511"));
        }

        SQLController sqlControl = ((RDBMSStoreManager)ec.getStoreManager()).getSQLController();
        PreparedStatement ps = sqlControl.getStatementForQuery(conn, queryStmt, rsTypeString, rsConcurrencyString);
View Full Code Here

        if (fetchDirExt != null)
        {
            fetchDir = (String)fetchDirExt;
            if (!fetchDir.equals("forward") && !fetchDir.equals("reverse") && !fetchDir.equals("unknown"))
            {
                throw new NucleusUserException(LOCALISER.msg("052512"));
            }
        }

        if (fetchDir.equals("reverse"))
        {
View Full Code Here

                    candidateClasses.add(cls);
                    candidateTables.add(table);
                    AbstractClassMetaData implCmd = storeMgr.getNucleusContext().getMetaDataManager().getMetaDataForClass(cls, clr);
                    if (implCmd.getIdentityType() != cmd.getIdentityType())
                    {
                        throw new NucleusUserException("You are querying an interface (" + cmd.getFullClassName() + ") " +
                            "yet one of its implementations (" + implCmd.getFullClassName() + ") " +
                            " uses a different identity type!");
                    }
                    else if (cmd.getIdentityType() == IdentityType.APPLICATION)
                    {
                        if (cmd.getPKMemberPositions().length != implCmd.getPKMemberPositions().length)
                        {
                            throw new NucleusUserException("You are querying an interface (" + cmd.getFullClassName() + ") " +
                                "yet one of its implementations (" + implCmd.getFullClassName() + ") " +
                                " has a different number of PK members!");
                        }
                    }
                }
View Full Code Here

     */
    protected Object performExecute(Map parameters)
    {
        if (parameters.size() != (parameterNames != null ? parameterNames.length : 0))
        {
            throw new NucleusUserException(LOCALISER_RDBMS.msg("059019",
                "" + parameterNames.length,"" + parameters.size()));
        }

        if (type == BULK_DELETE || type == BULK_UPDATE)
        {
View Full Code Here

            stmtMappings[fieldNumber] = new StatementMappingIndex(m);
        }
        if (columnFieldNumberMap.size() == 0)
        {
            // None of the fields in the class have columns in the datastore table!
            throw new NucleusUserException(LOCALISER.msg("059030", candidateClass.getName())).setFatal();
        }

        // Generate id column field information for later checking the id is present
        DatastoreClass table = storeMgr.getDatastoreClass(candidateClass.getName(), clr);
        PersistableMapping idMapping = (PersistableMapping)table.getIdMapping();
        String[] idColNames = new String[idMapping.getNumberOfDatastoreMappings()];
        boolean[] idColMissing = new boolean[idMapping.getNumberOfDatastoreMappings()];
        for (int i=0;i<idMapping.getNumberOfDatastoreMappings();i++)
        {
            DatastoreMapping m = idMapping.getDatastoreMapping(i);
            idColNames[i] = m.getDatastoreField().getIdentifier().toString();
            idColMissing[i] = true;
        }

        // Generate discriminator/version information for later checking they are present
        String discriminatorColName = table.getDiscriminatorMapping(false) != null ?
                table.getDiscriminatorMapping(false).getDatastoreMapping(0).getDatastoreField().getIdentifier().toString() : null;
        String versionColName = table.getVersionMapping(false) != null ?
                table.getVersionMapping(false).getDatastoreMapping(0).getDatastoreField().getIdentifier().toString() : null;
        boolean discrimMissing = (discriminatorColName != null);
        boolean versionMissing = true;
        if (versionColName == null)
        {
            versionMissing = false;
        }

        // Go through the fields of the ResultSet and map to the required fields in the candidate
        // Note that we check the existence of the columns again here even though they were checked at compilation
        // TODO This could be removed from here since its now done at compile time
        ResultSetMetaData rsmd = rs.getMetaData();
        HashSet remainingColumnNames = new HashSet(columnFieldNumberMap.size());
        int colCount = rsmd.getColumnCount();
        int[] datastoreIndex = null;
        int[] versionIndex = null;

        int[] matchedFieldNumbers = new int[colCount];
        int fieldNumberPosition = 0;
        for (int colNum=1; colNum<=colCount; ++colNum)
        {
            String colName = rsmd.getColumnName(colNum);

            // Find the field for this column
            int fieldNumber = -1;
            Integer fieldNum = (Integer)columnFieldNumberMap.get(colName);
            if (fieldNum == null)
            {
                // Try column name in lowercase
                fieldNum = (Integer)columnFieldNumberMap.get(colName.toLowerCase());
                if (fieldNum == null)
                {
                    // Try column name in UPPERCASE
                    fieldNum = (Integer)columnFieldNumberMap.get(colName.toUpperCase());
                }
            }

            if (fieldNum != null)
            {
                fieldNumber = fieldNum.intValue();
            }
            if (fieldNumber >= 0)
            {
                int[] exprIndices = null;
                if (stmtMappings[fieldNumber].getColumnPositions() != null)
                {
                    exprIndices = new int[stmtMappings[fieldNumber].getColumnPositions().length+1];
                    for (int i=0;i<stmtMappings[fieldNumber].getColumnPositions().length;i++)
                    {
                        exprIndices[i] = stmtMappings[fieldNumber].getColumnPositions()[i];
                    }
                    exprIndices[exprIndices.length-1] = colNum;
                }
                else
                {
                    exprIndices = new int[] {colNum};
                }
                stmtMappings[fieldNumber].setColumnPositions(exprIndices);
                remainingColumnNames.remove(colName);
                matchedFieldNumbers[fieldNumberPosition++] = fieldNumber;
            }

            if (versionColName != null && colName.equals(versionColName))
            {
                // Identify the location of the version column
                versionIndex = new int[1];
                versionIndex[0] = colNum;
                versionMissing = false;
            }

            if (candidateCmd.getIdentityType() == IdentityType.DATASTORE)
            {
                // Check for existence of id column, allowing for any RDBMS using quoted identifiers
                if (columnNamesAreTheSame(dba, idColNames[0], colName))
                {
                    datastoreIndex = new int[1];
                    datastoreIndex[0] = colNum;
                    idColMissing[0] = false;
                }
            }
            else if (candidateCmd.getIdentityType() == IdentityType.APPLICATION)
            {
                for (int j=0;j<idColNames.length;j++)
                {
                    // Check for existence of id column, allowing for any RDBMS using quoted identifiers
                    if (columnNamesAreTheSame(dba, idColNames[j], colName))
                    {
                        idColMissing[j] = false;
                    }
                }
            }
            if (discrimMissing && columnNamesAreTheSame(dba, discriminatorColName, colName))
            {
                discrimMissing = false;
            }
            else if (versionMissing && columnNamesAreTheSame(dba, versionColName, colName))
            {
                versionMissing = false;
            }
        }

        // Set the field numbers found to match what we really have
        int[] fieldNumbers = new int[fieldNumberPosition];
        for (int i=0;i<fieldNumberPosition;i++)
        {
            fieldNumbers[i] = matchedFieldNumbers[i];
        }

        if (discrimMissing)
        {
            throw new NucleusUserException(LOCALISER_RDBMS.msg("059014",
                inputSQL, candidateClass.getName(), discriminatorColName));
        }
        if (versionMissing)
        {
            throw new NucleusUserException(LOCALISER_RDBMS.msg("059015",
                inputSQL, candidateClass.getName(), versionColName));
        }
        for (int i=0;i<idColMissing.length;i++)
        {
            if (idColMissing[i])
            {
                throw new NucleusUserException(LOCALISER_RDBMS.msg("059013",
                    inputSQL, candidateClass.getName(), idColNames[i]));
            }
        }

        StatementClassMapping mappingDefinition = new StatementClassMapping();
View Full Code Here

TOP

Related Classes of org.datanucleus.exceptions.NucleusUserException

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.