Package org.jpox.store.mapped

Examples of org.jpox.store.mapped.DatastoreField


    getStoreManager().getMappingManager().createDatastoreMapping(sequenceNameMapping, storeMgr, colSequenceName,
            String.class.getName());

        // "NEXT_VAL" column
        nextValMapping = dba.getMapping(Long.class, storeMgr);
        DatastoreField colNextVal=addDatastoreField(Long.class.getName(),
            idFactory.newDatastoreFieldIdentifier(nextValColumnName), nextValMapping, null);
    getStoreManager().getMappingManager().createDatastoreMapping(nextValMapping, storeMgr, 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.supportsLockWithSelectForUpdate())
        {
            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


            AbstractTable refTable = (AbstractTable)storeMgr.getDatastoreClass(idFactory.newDatastoreContainerIdentifier(fki.pkTableName));
            if (refTable != null)
            {
                DatastoreIdentifier colName = idFactory.newIdentifier(IdentifierFactory.COLUMN, fki.fkColumnName);
                DatastoreIdentifier refColName = idFactory.newIdentifier(IdentifierFactory.COLUMN, fki.pkColumnName);
                DatastoreField col = (DatastoreField) columnsByName.get(colName);
                DatastoreField refCol = (DatastoreField) refTable.columnsByName.get(refColName);
                if (col != null && refCol != null)
                {
                    fk.addDatastoreField(col, refCol);
                }
                else
View Full Code Here

                                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.isAllowsNullSet()) ||
                                    (colmd != null && colmd.isAllowsNullSet() && colmd.isAllowsNull()))
                                {
                                    // User either wants it nullable, or havent specified anything, so make it nullable
                                    refColumn.setNullable();
                                }

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

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

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

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

        return indexMapping;
View Full Code Here

                    }

                    boolean found = false;
                    if (acmd.getIdentityType() == IdentityType.DATASTORE)
                    {
                        DatastoreField df = dc.getDataStoreObjectIdMapping().getDataStoreMapping(0).getDatastoreField();
                        if( df.getIdentifier().getIdentifier().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(om, 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.getFieldMapping(apmd);
                            for(int l=0; l<mapping.getDataStoreMappings().length && !found; l++)
                            {
                                DatastoreField df = mapping.getDataStoreMapping(l).getDatastoreField();
                                if( df.getIdentifier().getIdentifier().equals(columnNames[j]))
                                {
                                    fieldColumns.put(columnNames[j], apmd);
                                    columnsInThisType.add(columnNames[j]);
                                    fmds[j] = apmd;
                                    found = true;
View Full Code Here

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

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

        state = TABLE_STATE_INITIALIZED;
    }
View Full Code Here

        {
            // No name so generate one
            identifier = ((RDBMSIdentifierFactory)storeMgr.getIdentifierFactory()).newAdapterIndexFieldIdentifier();
        }

        DatastoreField column = table.addDatastoreField(mapping.getType(), identifier, mapping, colmd);
        storeMgr.getMappingManager().createDatastoreMapping(mapping, storeMgr, column, mapping.getJavaType().getName());
        if (pk)
        {
            column.setAsPrimaryKey();
        }

        return column;
    }
View Full Code Here

                        {
                            // User defined name, so we use that.
                            identifier = idFactory.newDatastoreFieldIdentifier(colmd.getName());
                        }

                        DatastoreField column = table.addDatastoreField(javaType.getName(), identifier, refDatastoreMapping, colmd);
                        ((Column) m.getDataStoreMapping(i).getDatastoreField()).copyConfigurationTo(column);
                        if (isPrimaryKey)
                        {
                            column.setAsPrimaryKey();
                        }
                        if (isNullable)
                        {
                            column.setNullable();
                        }

                        storeMgr.getMappingManager().createDatastoreMapping(refDatastoreMapping, storeMgr, column,
                            m.getDataStoreMapping(i).getJavaTypeMapping().getJavaTypeForDatastoreMapping(i));
                    }
                    catch (DuplicateColumnNameException ex)
                    {
                      throw new JPOXUserException("Cannot create column for field "+fmd.getFullFieldName()+" column metadata "+colmd,ex);
                    }
                    ((PersistenceCapableMapping) container).addJavaTypeMapping(refDatastoreMapping);
                }
            }
        }
        else
        {
            // Non-PC mapping
            // Add column for the field
            DatastoreField column = null;
            ColumnMetaData colmd = null;
            if (columnMetaData != null && columnMetaData.length > 0)
            {
                colmd = columnMetaData[0];
            }

            DatastoreIdentifier identifier = null;
            if (colmd != null && colmd.getName() != null)
            {
                // User specified name
                identifier = idFactory.newDatastoreFieldIdentifier(colmd.getName());
            }
            else
            {
                // No user-supplied name so generate one
                identifier = ((RDBMSIdentifierFactory)idFactory).newJoinTableFieldIdentifier(fmd, null, null,
                    storeMgr.getOMFContext().getTypeManager().isDefaultEmbeddedType(javaType), fieldRole);
            }
            column = table.addDatastoreField(javaType.getName(), identifier, mapping, colmd);
            storeMgr.getMappingManager().createDatastoreMapping(mapping, storeMgr, column,
                mapping.getJavaTypeForDatastoreMapping(0));

            if (isNullable)
            {
                column.setNullable();
            }
        }

        return mapping;
    }
View Full Code Here

TOP

Related Classes of org.jpox.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.