Package org.datanucleus.store.mapped

Examples of org.datanucleus.store.mapped.DatastoreField


                                    else
                                    {
                                        // User-defined name
                                        identifier = idFactory.newDatastoreFieldIdentifier(colmd.getName());
                                    }
                                    DatastoreField refColumn = addDatastoreField(mapping.getJavaType().getName(), identifier, mapping, colmd);
                                    ((Column)refDatastoreMapping.getDatastoreField()).copyConfigurationTo(refColumn);

                                    if (colmd == null || (colmd != null && colmd.getAllowsNull() == null) ||
                                            (colmd != null && colmd.getAllowsNull() != null && colmd.isAllowsNull()))
                                    {
                                        // User either wants it nullable, or haven't specified anything, so make it nullable
                                        refColumn.setNullable();
                                    }

                                    fkMapping.addDatastoreMapping(getStoreManager().getMappingManager().createDatastoreMapping(mapping, refColumn, refDatastoreMapping.getJavaTypeMapping().getJavaType().getName()));
                                    ((PersistableMapping)fkMapping).addJavaTypeMapping(mapping);
                                }
View Full Code Here


            // No name defined so generate one
            indexColumnName = idFactory.newForeignKeyFieldIdentifier(mmd, null, null,
                storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(indexType), FieldRole.ROLE_INDEX);
        }

        DatastoreField column = addDatastoreField(indexType.getName(), indexColumnName, indexMapping, colmd);
        if (colmd == null || (colmd != null && colmd.getAllowsNull() == null) ||
            (colmd != null && colmd.getAllowsNull() != null && colmd.isAllowsNull()))
        {
            // User either wants it nullable, or havent specified anything, so make it nullable
            column.setNullable();
        }

        storeMgr.getMappingManager().createDatastoreMapping(indexMapping, column, indexType.getName());

        return indexMapping;
View Full Code Here

            {
                CandidateKey uniKey = new CandidateKey(this);
                IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
                for (int i=0;i<colmds.length;i++)
                {
                    DatastoreField col = getDatastoreField(idFactory.newDatastoreFieldIdentifier(colmds[i].getName()));
                    if (col != null)
                    {
                        uniKey.addDatastoreField(col);
                    }
                    else
View Full Code Here

    public void initialize(ClassLoaderResolver clr)
    {
        assertIsUninitialized();

    JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(int.class);
    DatastoreField column = addDatastoreField(int.class.getName(),
            storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier("UNUSED"), mapping, null);
    getStoreManager().getMappingManager().createDatastoreMapping(mapping, column, int.class.getName());

        state = TABLE_STATE_INITIALIZED;
    }
View Full Code Here

                {
                    String fkColumnName = (String)fkInfo.getProperty("fk_column_name");
                    String pkColumnName = (String)fkInfo.getProperty("pk_column_name");
                    DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierType.COLUMN, fkColumnName);
                    DatastoreIdentifier refColName = idFactory.newIdentifier(IdentifierType.COLUMN, pkColumnName);
                    DatastoreField col = columnsByName.get(colName);
                    DatastoreField refCol = refTable.columnsByName.get(refColName);
                    if (col != null && refCol != null)
                    {
                        fk.addDatastoreField(col, refCol);
                    }
                    else
View Full Code Here

                    }

                    boolean found = false;
                    if (acmd.getIdentityType() == IdentityType.DATASTORE)
                    {
                        DatastoreField df = dc.getDatastoreObjectIdMapping().getDatastoreMapping(0).getDatastoreField();
                        if (df.getIdentifier().getIdentifierName().equals(columnNames[j]))
                        {
                            //add +1 because result sets in jdbc starts with 1
                            int datastoreIdentityExpressionIndex = j+1;
                            //get object id if datastore identifier
                            if (dc.getDatastoreObjectIdMapping() != null)
                            {
                                id = dc.getDatastoreObjectIdMapping().getObject(ec, rs, new int[] {datastoreIdentityExpressionIndex});
                            }
                            found=true;
                        }
                    }
                    for (int k=0; k<acmd.getNoOfManagedMembers()+acmd.getNoOfInheritedManagedMembers() && !found; k++)
                    {
                        AbstractMemberMetaData apmd = acmd.getMetaDataForManagedMemberAtAbsolutePosition(k);
                        if (persistentTypes[i].getColumnForField(apmd.getName()) != null)
                        {
                            if (persistentTypes[i].getColumnForField(apmd.getName()).equals(columnNames[j]))
                            {
                                fieldColumns.put(columnNames[j], apmd);
                                columnsInThisType.add(columnNames[j]);
                                fmds[j] = apmd;
                                found = true;
                            }
                        }
                        else
                        {
                            JavaTypeMapping mapping = dc.getMemberMapping(apmd);
                            for(int l=0; l<mapping.getDatastoreMappings().length && !found; l++)
                            {
                                DatastoreField df = mapping.getDatastoreMapping(l).getDatastoreField();
                                if (df.getIdentifier().getIdentifierName().equals(columnNames[j]))
                                {
                                    fieldColumns.put(columnNames[j], apmd);
                                    columnsInThisType.add(columnNames[j]);
                                    fmds[j] = apmd;
                                    found = true;
View Full Code Here

        colSequenceName.getColumnMetaData().setJdbcType("VARCHAR");
    getStoreManager().getMappingManager().createDatastoreMapping(sequenceNameMapping, colSequenceName, String.class.getName());

        // "NEXT_VAL" column
        nextValMapping = storeMgr.getMappingManager().getMapping(Long.class);
        DatastoreField colNextVal=addDatastoreField(Long.class.getName(),
            idFactory.newDatastoreFieldIdentifier(nextValColumnName), nextValMapping, null);
    getStoreManager().getMappingManager().createDatastoreMapping(nextValMapping, colNextVal, Long.class.getName());

        // Set up JDBC statements for supported operations
        insertStmt = "INSERT INTO " + identifier.getFullyQualifiedName(false) + " (" + colSequenceName.getIdentifier() + "," + colNextVal.getIdentifier() +
            ") VALUES (?,?)";
        incrementByStmt = "UPDATE " + identifier.getFullyQualifiedName(false) + " SET " + colNextVal.getIdentifier() + "=(" +
            colNextVal.getIdentifier() + "+?) WHERE " + colSequenceName.getIdentifier() + "=?";
        deleteStmt = "DELETE FROM " + identifier.getFullyQualifiedName(false) + " WHERE " + colSequenceName.getIdentifier() + "=?";
        deleteAllStmt = "DELETE FROM " + identifier.getFullyQualifiedName(false);
        fetchStmt = "SELECT " + colNextVal.getIdentifier() + " FROM " + identifier.getFullyQualifiedName(false) + " WHERE " +
            colSequenceName.getIdentifier() + "=?";
        if (dba.supportsOption(RDBMSAdapter.LOCK_WITH_SELECT_FOR_UPDATE))
        {
            fetchStmt += " FOR UPDATE";
        }
        fetchAllStmt = "SELECT " + colNextVal.getIdentifier() + "," + colSequenceName.getIdentifier() +
            " FROM " + identifier.getFullyQualifiedName(false) + " ORDER BY " + colSequenceName.getIdentifier();

        state = TABLE_STATE_INITIALIZED;
    }
View Full Code Here

            // Loop through each id column in the reference table and add the same here
            // applying the required names from the columnContainer
            for (int j=0; j<mapping.getNumberOfDatastoreMappings(); j++)
            {
                JavaTypeMapping m = masterMapping;
                DatastoreField refColumn = mapping.getDatastoreMapping(j).getDatastoreField();
                if (mapping instanceof PersistableMapping)
                {
                    m = storeMgr.getMappingManager().getMapping(clr.classForName(refColumn.getJavaTypeMapping().getType()));
                    ((PersistableMapping)masterMapping).addJavaTypeMapping(m);
                }

                ColumnMetaData userdefinedColumn = null;
                if (userdefinedCols != null)
                {
                    for (int k=0;k<userdefinedCols.length;k++)
                    {
                        if (refColumn.getIdentifier().toString().equals(userdefinedCols[k].getTarget()))
                        {
                            userdefinedColumn = userdefinedCols[k];
                            break;
                        }
                    }
                    if (userdefinedColumn == null && nextUserdefinedCol < userdefinedCols.length)
                    {
                        userdefinedColumn = userdefinedCols[nextUserdefinedCol++];
                    }
                }

                // Add this application identity column
                DatastoreField idColumn = null;
                if (userdefinedColumn != null)
                {
                    // User has provided a name for this column
                    // Currently we only use the column namings from the users definition but we could easily
                    // take more of their details.
                    idColumn = addDatastoreField(refColumn.getStoredJavaType(),
                        storeMgr.getIdentifierFactory().newIdentifier(IdentifierType.COLUMN, userdefinedColumn.getName()),
                        m, refColumn.getColumnMetaData());
                }
                else
                {
                    // No name provided so take same as superclass
                    idColumn = addDatastoreField(refColumn.getStoredJavaType(), refColumn.getIdentifier(),
                        m, refColumn.getColumnMetaData());
                }
                if (mapping != null && mapping.getDatastoreMapping(j).getDatastoreField().getColumnMetaData() != null)
                {
                    refColumn.copyConfigurationTo(idColumn);
                }
                idColumn.setAsPrimaryKey();

                // Set the column type based on the field.getType()
                getStoreManager().getMappingManager().createDatastoreMapping(m, idColumn, refColumn.getJavaTypeMapping().getType());
            }
View Full Code Here

            {
                CandidateKey uniKey = new CandidateKey(this);
                IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
                for (int i=0;i<colmds.length;i++)
                {
                    DatastoreField col = getDatastoreField(idFactory.newDatastoreFieldIdentifier(colmds[i].getName()));
                    if (col != null)
                    {
                        uniKey.addDatastoreField(col);
                    }
                    else
View Full Code Here

            {
                // Name defined so just generate identifier
                id = idFactory.newDatastoreFieldIdentifier(colmd.getName());
            }
        }
        DatastoreField column = datastoreContainer.addDatastoreField(getType(), id, this, colmd);
        datastoreContainer.getStoreManager().getMappingManager().createDatastoreMapping(delegate, column,
            getType());
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.mapped.DatastoreField

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.