Package org.datanucleus.metadata

Examples of org.datanucleus.metadata.ColumnMetaData


    /* (non-Javadoc)
     * @see javax.jdo.metadata.DatastoreIdentityMetadata#newColumnMetadata()
     */
    public ColumnMetadata newColumnMetadata()
    {
        ColumnMetaData internalColmd = getInternal().newColumnMetaData();
        ColumnMetadataImpl colmd = new ColumnMetadataImpl(internalColmd);
        colmd.parent = this;
        return colmd;
    }
View Full Code Here


        VersionMetaData vermd = datastoreContainer.getVersionMetaData();

        // Currently we only use a single column mapping for versioning.
        // The MetaData supports multiple columns and so we could extend this in the future
        // to use all MetaData information.
        ColumnMetaData versionColumnMetaData = vermd.getColumnMetaData();
        ColumnMetaData colmd;
        IdentifierFactory idFactory = datastoreContainer.getStoreManager().getIdentifierFactory();
        DatastoreIdentifier id = null;
        if (versionColumnMetaData == null)
        {
            // No column name so generate a default
            id = idFactory.newVersionFieldIdentifier();
            colmd = new ColumnMetaData();
            colmd.setName(id.getIdentifierName());
            datastoreContainer.getVersionMetaData().setColumnMetaData(colmd);
        }
        else
        {
            // Column metadata defined
            colmd = versionColumnMetaData;
            if (colmd.getName() == null)
            {
                // No name defined so create one and set it
                id = idFactory.newVersionFieldIdentifier();
                colmd.setName(id.getIdentifierName());
            }
            else
            {
                // 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

                    // Create physical datastore columns where we require a FK link to the related table.
                    if (createDatastoreMappings)
                    {
                        // Find the Column MetaData that maps to the referenced datastore field
                        ColumnMetaData colmd = correspondentColumnsMapping.getColumnMetaDataByIdentifier(
                            refDatastoreMapping.getDatastoreField().getIdentifier());
                        if (colmd == null)
                        {
                            throw new NucleusUserException(LOCALISER.msg("041038",
                                refDatastoreMapping.getDatastoreField().getIdentifier(), toString())).setFatal();
View Full Code Here

          identityStrategyUsed = true;
          pkType = cmd.getMetaDataForManagedMemberAtAbsolutePosition(cmd.getPKMemberPositions()[0]).getType();
        } else if (cmd.getIdentityType() == IdentityType.DATASTORE) {
          identityStrategyUsed = true;
          pkType = Key.class;
          ColumnMetaData colmd = cmd.getIdentityMetaData().getColumnMetaData();
          if (colmd != null) {
            if ("varchar".equalsIgnoreCase(colmd.getJdbcType()) || "char".equalsIgnoreCase(colmd.getJdbcType())) {
              pkType = String.class;
            } else if ("integer".equalsIgnoreCase(colmd.getJdbcType()) || "numeric".equalsIgnoreCase(colmd.getJdbcType())) {
              pkType = Long.class;
            }
          }
        }
      }
View Full Code Here

                {
                    discrimMetaData.setStrategy(DiscriminatorStrategy.CLASS_NAME); // Fallback to class name
                }

                // Set column for discriminator
                ColumnMetaData disColmd = new ColumnMetaData();
                disColmd.setAllowsNull(Boolean.TRUE);

                DiscriminatorMetaData embDismd = emd.getDiscriminatorMetaData();
                if (embDismd != null && embDismd.getColumnMetaData() != null)
                {
                    disColmd.setName(embDismd.getColumnMetaData().getName());
                }
                else
                {
                    ColumnMetaData colmd = dismd.getColumnMetaData();
                    if (colmd != null && colmd.getName() != null)
                    {
                        disColmd.setName(colmd.getName());
                    }
                }
                discrimMetaData.setColumnMetaData(disColmd);

                discrimMapping = DiscriminatorMapping.createDiscriminatorMapping(datastoreContainer, discrimMetaData);
View Full Code Here

        DatastoreIdentifier id = null;
        if (dismd.getColumnMetaData() == null)
        {
            // No column name so generate a default
            id = idFactory.newDiscriminatorFieldIdentifier();
            ColumnMetaData colmd = new ColumnMetaData();
            colmd.setName(id.getIdentifierName());
            dismd.setColumnMetaData(colmd);
        }
        else
        {
            // Column metadata defined
            ColumnMetaData colmd = dismd.getColumnMetaData();
            if (colmd.getName() == null)
            {
                // No name defined so create one and set it
                id = idFactory.newDiscriminatorFieldIdentifier();
                colmd.setName(id.getIdentifierName());
            }
            else
            {
                // Name defined so just generate identifier
                id = idFactory.newDatastoreFieldIdentifier(colmd.getName());
            }
        }

        DatastoreField column = table.addDatastoreField(getType(), id, this, dismd.getColumnMetaData());
        table.getStoreManager().getMappingManager().createDatastoreMapping(delegate, column,
View Full Code Here

            return new DiscriminatorStringMapping(storeMgr.getDatastoreAdapter(), table,
                mapMgr.getMapping(String.class), dismd);
        }
        else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
        {
            ColumnMetaData disColmd = dismd.getColumnMetaData();
            if (disColmd != null && disColmd.getJdbcType() != null)
            {
                if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") ||
                        disColmd.getJdbcType().equalsIgnoreCase("BIGINT") ||
                        disColmd.getJdbcType().equalsIgnoreCase("NUMERIC"))
                {
                    return new DiscriminatorLongMapping(storeMgr.getDatastoreAdapter(), table,
                        mapMgr.getMapping(Long.class), dismd);
                }
                else
View Full Code Here

      AbstractClassMetaData cmd) {
    datastoreIDMapping = new OIDMapping();
    datastoreIDMapping.initialize(storeMgr, cmd.getFullClassName());

    // Create a ColumnMetaData in the container if none is defined
    ColumnMetaData colmd;
    if (columnMetaData == null) {
      colmd = new ColumnMetaData();
    } else {
      colmd = columnMetaData;
    }
    if (colmd.getName() == null) {
      // Provide default column naming if none is defined
      if (refTable != null) {
        colmd.setName(storeMgr.getIdentifierFactory()
            .newDatastoreFieldIdentifier(refTable.getIdentifier().getIdentifierName(),
                this.storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(OID.class),
                FieldRole.ROLE_OWNER).getIdentifierName());
      } else {
        colmd.setName(
            storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier(identifier.getIdentifierName(),
                this.storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(OID.class),
                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();
View Full Code Here

            }
          }
        }
      } else if (cmd.getIdentityType() == IdentityType.DATASTORE) {
        // datastore-identity
        ColumnMetaData colmd = null;
        if (cmd.getIdentityMetaData() != null
            && cmd.getIdentityMetaData().getColumnMetaData() != null) {
          // Try via <datastore-identity>...</datastore-identity>
          colmd = cmd.getIdentityMetaData().getColumnMetaData();
        }
View Full Code Here

      discriminatorMetaData = dismd;
      if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME) {
        discriminatorMapping = new DiscriminatorStringMapping(
            dba, this, dba.getMappingManager(storeMgr).getMapping(String.class));
      } else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP) {
        ColumnMetaData disColmd = dismd.getColumnMetaData();
        if (disColmd != null && disColmd.getJdbcType() != null) {
          if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER")
              || disColmd.getJdbcType().equalsIgnoreCase("BIGINT")
              || disColmd.getJdbcType().equalsIgnoreCase("NUMERIC")) {
            discriminatorMapping = new DiscriminatorLongMapping(dba, this, dba
                .getMappingManager(storeMgr).getMapping(Long.class));
          } else {
            discriminatorMapping = new DiscriminatorStringMapping(
                dba, this, dba.getMappingManager(storeMgr).getMapping(String.class));
View Full Code Here

TOP

Related Classes of org.datanucleus.metadata.ColumnMetaData

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.