Package org.datanucleus.store.mapped.mapping

Examples of org.datanucleus.store.mapped.mapping.MappingManager


        // Add the fields for this class (and any other superclasses that we need to manage the
        // fields for (inheritance-strategy="subclass-table" in the superclass)
        initializeForClass(cmd, clr);

        MappingManager mapMgr = storeMgr.getMappingManager();
        // Add Version where specified in MetaData
        // TODO If there is a superclass table that has a version we should omit from here even if in MetaData
        // See "getTableWithDiscriminator()" for the logic
        versionMetaData = cmd.getVersionMetaDataForTable();
        if (versionMetaData != null && versionMetaData.getFieldName() == null)
        {
            if (versionMetaData.getVersionStrategy() == VersionStrategy.NONE)
            {
                // No optimistic locking but the idiot wants a column for that :-)
                versionMapping = new VersionLongMapping(dba, this, mapMgr.getMapping(Long.class));
            }
            else if (versionMetaData.getVersionStrategy() == VersionStrategy.VERSION_NUMBER)
            {
                versionMapping = new VersionLongMapping(dba, this, mapMgr.getMapping(Long.class));
            }
            else if (versionMetaData.getVersionStrategy() == VersionStrategy.DATE_TIME)
            {
                if (!dba.supportsOption(RDBMSAdapter.DATETIME_STORES_MILLISECS))
                {
                    // TODO Localise this
                    throw new NucleusException("Class " + cmd.getFullClassName() + " is defined " +
                        "to use date-time versioning, yet this datastore doesnt support storing " +
                        "milliseconds in DATETIME/TIMESTAMP columns. Use version-number");
                }
                versionMapping = new VersionTimestampMapping(dba, this, mapMgr.getMapping(Timestamp.class));
            }
        }

        // Add Discriminator where specified in MetaData
        DiscriminatorMetaData dismd = cmd.getDiscriminatorMetaDataForTable();
        if (dismd != null)
        {
            discriminatorMetaData = dismd;
            if (storeMgr.getBooleanProperty("datanucleus.rdbms.discriminatorPerSubclassTable"))
            {
                // Backwards compatibility only. Creates discriminator in all subclass tables even though not needed
                // TODO Remove this in the future
                if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
                {
                    discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                        mapMgr.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,
                                mapMgr.getMapping(Long.class));
                        }
                        else
                        {
                            discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                mapMgr.getMapping(String.class));
                        }
                    }
                    else
                    {
                        discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                            mapMgr.getMapping(String.class));
                    }
                }
            }
            else
            {
                // Create discriminator column only in top most table that needs it
                ClassTable tableWithDiscrim = getTableWithDiscriminator();
                if (tableWithDiscrim == this)
                {
                    // No superclass with a discriminator so add it in this table
                    if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
                    {
                        discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                            mapMgr.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,
                                    mapMgr.getMapping(Long.class));
                            }
                            else
                            {
                                discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                    mapMgr.getMapping(String.class));
                            }
                        }
                        else
                        {
                            discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                mapMgr.getMapping(String.class));
                        }
                    }
                }
            }
        }
View Full Code Here


    {
        // Initialise the mappings available. Load all possible, and remove unsupported for this datastore
        RDBMSStoreManager storeMgr = (RDBMSStoreManager)handler.getStoreManager();
        ClassLoaderResolver clr = storeMgr.getNucleusContext().getClassLoaderResolver(null);
        PluginManager pluginMgr = storeMgr.getNucleusContext().getPluginManager();
        MappingManager mapMgr = storeMgr.getMappingManager();
        mapMgr.loadDatastoreMapping(pluginMgr, clr, getVendorID());

        // Load the types from plugin(s)
        handler.getSchemaData(mconn.getConnection(), "types", null);
    }
View Full Code Here

    {
        super.initialiseTypes(handler, mconn);

        // Re-register mapping for this adapter
        RDBMSStoreManager storeMgr = (RDBMSStoreManager)handler.getStoreManager();
        MappingManager mapMgr = storeMgr.getMappingManager();
        if (mapMgr instanceof RDBMSMappingManager)
        {
            RDBMSMappingManager rdbmsMapMgr = (RDBMSMappingManager)mapMgr;
            rdbmsMapMgr.deregisterDatastoreMappingsForJDBCType("VARBINARY");
            rdbmsMapMgr.registerDatastoreMapping("java.io.Serializable", TimesTenVarBinaryRDBMSMapping.class,
View Full Code Here

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

        IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
        MappingManager mapMgr = getStoreManager().getMappingManager();
        classMapping = mapMgr.getMapping(String.class);
        Column class_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("CLASS_NAME"), classMapping, null);
        mapMgr.createDatastoreMapping(classMapping, class_column, String.class.getName());
        class_column.getColumnMetaData().setLength(128);
        class_column.getColumnMetaData().setJdbcType("VARCHAR");
        class_column.setAsPrimaryKey();

        tableMapping = mapMgr.getMapping(String.class);
        Column table_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("TABLE_NAME"), tableMapping, null);
        mapMgr.createDatastoreMapping(tableMapping, table_column, String.class.getName());
        table_column.getColumnMetaData().setLength(128);
        table_column.getColumnMetaData().setJdbcType("VARCHAR");

        typeMapping = mapMgr.getMapping(String.class);
        Column type_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("TYPE"), typeMapping, null);
        mapMgr.createDatastoreMapping(typeMapping, type_column, String.class.getName());
        type_column.getColumnMetaData().setLength(4);
        type_column.getColumnMetaData().setJdbcType("VARCHAR");

        // TODO Change type to SMALLINT/BIT
        ownerMapping = mapMgr.getMapping(String.class);
        Column owner_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("OWNER"), ownerMapping, null);
        mapMgr.createDatastoreMapping(ownerMapping, owner_column, String.class.getName());
        owner_column.getColumnMetaData().setLength(2);
        owner_column.getColumnMetaData().setJdbcType("VARCHAR");

        versionMapping = mapMgr.getMapping(String.class);
        Column version_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("VERSION"), versionMapping, null);
        mapMgr.createDatastoreMapping(versionMapping, version_column, String.class.getName());
        version_column.getColumnMetaData().setLength(20);
        version_column.getColumnMetaData().setJdbcType("VARCHAR");

        interfaceNameMapping = mapMgr.getMapping(String.class);
        Column interfaceName_column=(Column) addDatastoreField(String.class.getName(),
            idFactory.newDatastoreFieldIdentifier("INTERFACE_NAME"), interfaceNameMapping, null);
        mapMgr.createDatastoreMapping(interfaceNameMapping, interfaceName_column, String.class.getName());
        interfaceName_column.getColumnMetaData().setLength(255);
        interfaceName_column.getColumnMetaData().setJdbcType("VARCHAR");
        interfaceName_column.setNullable();
       
        // Set up JDBC statements for supported operations
View Full Code Here

TOP

Related Classes of org.datanucleus.store.mapped.mapping.MappingManager

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.