Package org.datanucleus.store.mapped

Examples of org.datanucleus.store.mapped.DatastoreField


     */
    protected void addDatastoreField(String typeName)
    {
        MappedStoreManager storeMgr = datastoreContainer.getStoreManager();
        MappingManager mgr = storeMgr.getMappingManager();
        DatastoreField column = mgr.createDatastoreField(this, typeName, getNumberOfDatastoreFields());
        mgr.createDatastoreMapping(this, column, typeName);
    }
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

        if (mmd.getElementMetaData() != null && mmd.getElementMetaData().getColumnMetaData() != null &&
            mmd.getElementMetaData().getColumnMetaData().length > 0)
        {
            colmd = mmd.getElementMetaData().getColumnMetaData()[0];
        }
        DatastoreField col = mmgr.createDatastoreField(this, getType(), colmd);
        mmgr.createDatastoreMapping(this, mmd, 0, col);
    }
View Full Code Here

                FieldRole.ROLE_NONE).getIdentifierName());
      }
    }

    // Add the datastore identity column as the PK
    DatastoreField idColumn = addDatastoreField(OID.class.getName(),
        storeMgr.getIdentifierFactory().newIdentifier(IdentifierType.COLUMN, colmd.getName()),
        datastoreIDMapping, colmd);
    idColumn.setAsPrimaryKey();

    // Set the identity column type based on the IdentityStrategy
    String strategyName = cmd.getIdentityMetaData().getValueStrategy().toString();
    if (cmd.getIdentityMetaData().getValueStrategy().equals(IdentityStrategy.CUSTOM)) {
      strategyName = cmd.getIdentityMetaData().getValueStrategy().getCustomName();
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.getNumberOfDatastoreFields(); j++) {
        JavaTypeMapping m = masterMapping;
        DatastoreField refColumn = mapping.getDataStoreMapping(j).getDatastoreField();
        if (mapping instanceof PersistenceCapableMapping) {
          m = storeMgr.getMappingManager()
              .getMapping(clr.classForName(refColumn.getJavaTypeMapping().getType()));
          ((PersistenceCapableMapping) masterMapping).addJavaTypeMapping(m);
        }

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

        // Add this application identity column
        DatastoreField idColumn;
        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

    }

    // if the relationship is in a base class with multiple subclasses, each
    // subclass will try to add the index column.  We need to avoid adding
    // the same column twice.
    DatastoreField column = datastorePropertiesByName.get(indexColumnName.getIdentifierName());
    if (column == null) {
      column = addDatastoreField(indexType.getName(), indexColumnName, indexMapping, colmd);
    }
    if (colmd == null || (colmd.getAllowsNull() == null) ||
        (colmd.getAllowsNull() != null && colmd.isAllowsNull())) {
      // User either wants it nullable, or havent specified anything, so make it nullable
      column.setNullable();
    }

    DatastoreFKMapping fkMapping =
        (DatastoreFKMapping) storeMgr.getMappingManager().createDatastoreMapping(
            indexMapping, column, indexType.getName());
View Full Code Here

                        DatastoreMapping datastoreMapping = embFmdMapping.getDataStoreMapping(j);
                        this.addDataStoreMapping(datastoreMapping);
                        if (fmd.isPrimaryKey())
                        {
                            // Overall embedded field should be part of PK, so make all datastore fields part of it
                            DatastoreField datastoreFld = datastoreMapping.getDatastoreField();
                            if (datastoreFld != null)
                            {
                                datastoreFld.setAsPrimaryKey();
                            }
                        }
                    }
                }
            }
View Full Code Here

                            refDatastoreMapping.getDatastoreField().getIdentifier(), toString())).setFatal();
                    }

                    // Create a Datastore field to equate to the referenced classes datastore field
                    MappingManager mmgr = datastoreContainer.getStoreManager().getMappingManager();
                    DatastoreField col = mmgr.createDatastoreField(mmd, datastoreContainer, mapping,
                        colmd, refDatastoreMapping.getDatastoreField(), clr);

                    // Add its datastore mapping
                    DatastoreMapping datastoreMapping = mmgr.createDatastoreMapping(mapping, col, refDatastoreMapping.getJavaTypeMapping().getJavaTypeForDatastoreMapping(i));
                    this.addDataStoreMapping(datastoreMapping);
View Full Code Here

        if (mmd.getValueMetaData() != null && mmd.getValueMetaData().getColumnMetaData() != null &&
            mmd.getValueMetaData().getColumnMetaData().length > 0)
        {
            colmd = mmd.getValueMetaData().getColumnMetaData()[0];
        }
        DatastoreField col = mmgr.createDatastoreField(this,getType(), colmd);
        mmgr.createDatastoreMapping(this, mmd, 0, col);
    }
View Full Code Here

            MappingManager mapMgr = datastoreContainer.getStoreManager().getMappingManager();
            JavaTypeMapping mapping = mapMgr.getMapping(String.class);
            mapping.setMemberMetaData(mmd);
            mapping.setDatastoreContainer(datastoreContainer);
            mapping.setRoleForMember(roleForMember);
            DatastoreField col = mapMgr.createDatastoreField(mapping, String.class.getName(), 0);
            mapMgr.createDatastoreMapping(mapping, mmd, 0, col);
            this.addJavaTypeMapping(mapping);
        }
    }
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.