Package org.jpox.store.mapped

Examples of org.jpox.store.mapped.DatastoreIdentifier


        {
            // Can't create a FK if we don't know where it goes to
            JPOXLogger.DATASTORE_SCHEMA.warn(LOCALISER.msg("058105", acmd.getFullClassName()));
            return null;
        }
        DatastoreIdentifier tableId = storeMgr.getIdentifierFactory().newDatastoreContainerIdentifier(fkmd.getTable());
        ClassTable refTable = (ClassTable)storeMgr.getDatastoreClass(tableId);
        if (refTable == null)
        {
            // TODO Go to the datastore and query for this table to get the columns of the PK
            JPOXLogger.DATASTORE_SCHEMA.warn(LOCALISER.msg("058106", acmd.getFullClassName(),
                fkmd.getTable()));
            return null;
        }
        PrimaryKey pk = refTable.getPrimaryKey();
        List targetCols = pk.getColumns();

        // Generate the columns for the source of the foreign-key
        List sourceCols = new ArrayList();
        ColumnMetaData[] colmds = fkmd.getColumnMetaData();
        AbstractMemberMetaData[] fmds = fkmd.getMemberMetaData();
        if (colmds != null && colmds.length > 0)
        {
            // FK specified via <column>
            for (int i=0;i<colmds.length;i++)
            {
                // Find the column and add to the source columns for the FK
                DatastoreIdentifier colId = storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier(colmds[i].getName());
                Column sourceCol = (Column)columnsByName.get(colId);
                if (sourceCol == null)
                {
                    JPOXLogger.DATASTORE_SCHEMA.warn(LOCALISER.msg("058107",
                        acmd.getFullClassName(), fkmd.getTable(), colmds[i].getName(), toString()));
View Full Code Here


        // a). Columns specified directly
        if (colmds != null && colmds.length > 0)
        {
            for (int i=0;i<colmds.length;i++)
            {
                DatastoreIdentifier colName = storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier(colmds[i].getName());
                Column col = (Column)columnsByName.get(colName);
                if (col == null)
                {
                    JPOXLogger.DATASTORE.warn(LOCALISER.msg("058202",
                        toString(), ck.getName(), colmds[i].getName()));
View Full Code Here

        int ckNum = 0;

        RDBMSIdentifierFactory idFactory = (RDBMSIdentifierFactory)storeMgr.getIdentifierFactory();
        while (cks.hasNext())
        {
            DatastoreIdentifier ckName = idFactory.newCandidateKeyIdentifier(this, ++ckNum);
            CandidateKey ck = (CandidateKey)cks.next();
            ck.setName(ckName.getIdentifier());

            stmts.add(dba.getAddCandidateKeyStatement(ck, idFactory));
        }

        return stmts;
View Full Code Here

    {
        Class indexType = Integer.class;
        JavaTypeMapping indexMapping = new IndexMapping();
        indexMapping.initialize(dba, indexType.getName());
        IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
        DatastoreIdentifier indexColumnName = null;
        ColumnMetaData colmd = null;

        // Allow for any user definition in OrderMetaData
        OrderMetaData omd = fmd.getOrderMetaData();
        if (omd != null)
View Full Code Here

        {
            throw new IncompatibleQueryElementTypeException(valueType, candidateClass);
        }

        ClassLoaderResolver clr = sm.getObjectManager().getClassLoaderResolver();
        DatastoreIdentifier mapTableAlias = storeMgr.getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, "map");
        QueryExpression stmt = dba.newQueryStatement(mapTable, mapTableAlias, clr);

        // Join to owner
        ScalarExpression ownerExpr = ownerMapping.newScalarExpression(stmt, stmt.getMainTableExpression());
        ScalarExpression ownerVal = ownerMapping.newLiteral(stmt, sm.getObject());
View Full Code Here

        {
            throw new IncompatibleQueryElementTypeException(elementType, candidateClass);
        }

        ClassLoaderResolver clr = sm.getObjectManager().getClassLoaderResolver();
        DatastoreIdentifier listTableAlias = storeMgr.getIdentifierFactory().newIdentifier(
            IdentifierFactory.TABLE, listName);

        // QueryStatement for the join table
        QueryExpression stmt = dba.newQueryStatement(containerTable, listTableAlias, clr);

        // Join to the owner
        ScalarExpression ownerExpr = ownerMapping.newScalarExpression(stmt, stmt.getTableExpression(listTableAlias));
        ScalarExpression ownerVal = ownerMapping.newLiteral(stmt, sm.getObject());
        stmt.andCondition(ownerExpr.eq(ownerVal), true);

        if (storeMgr.getOMFContext().getTypeManager().isSupportedType(candidateClass))
        {
            // Non-PC(embedded) - select the join table element
            stmt.select(listTableAlias, elementMapping);
        }
        else
        {
            // PC
            DatastoreClass candidateTable = storeMgr.getDatastoreClass(candidateClass, clr);

            // Add the element table to the query, called "LIST_ELEMENTS"
            DatastoreIdentifier elementTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
                IdentifierFactory.TABLE, "LIST_ELEMENTS");
            LogicSetExpression elementTblExpr = stmt.newTableExpression(candidateTable, elementTblAlias);

            // Inner Join from the ID of the element to the element mapping of the join table
            JavaTypeMapping elementTableID = candidateTable.getIDMapping();
View Full Code Here

                orderColmd = new ColumnMetaData(fmd, fmd.getValueForExtension("adapter-column-name"));
            }
            else
            {
                // No column name so use default
                DatastoreIdentifier id =
                    ((RDBMSIdentifierFactory)storeMgr.getIdentifierFactory()).newIndexFieldIdentifier();
                orderColmd = new ColumnMetaData(fmd, id.getIdentifier());
            }
            orderMapping = dba.getMapping(int.class, storeMgr); // JDO2 spec [18.5] order column is assumed to be "int"
            ColumnCreator.createIndexColumn(orderMapping, storeMgr, clr, this, orderColmd, pkRequired && !pkColsSpecified);
            if (JPOXLogger.DATASTORE.isDebugEnabled())
            {
View Full Code Here

        // Set the index name if required
        if (imd.getName() != null)
        {
            IdentifierFactory idFactory = table.getStoreManager().getIdentifierFactory();
            DatastoreIdentifier idxId = idFactory.newIdentifier(IdentifierFactory.INDEX, imd.getName());
            index.setName(idxId.toString());
        }

        // Field-level index so use all columns for the field
        int countFields = fieldMapping.getNumberOfDatastoreFields();
        for (int j=0; j<countFields; j++)
View Full Code Here

        // Set the key name if required
        if (umd.getName() != null)
        {
            IdentifierFactory idFactory = table.getStoreManager().getIdentifierFactory();
            DatastoreIdentifier ckId = idFactory.newIdentifier(IdentifierFactory.CANDIDATE_KEY, umd.getName());
            ck.setName(ckId.toString());
        }

        // Field-level index so use all columns for the field
        int countFields = fieldMapping.getNumberOfDatastoreFields();
        for (int j=0; j<countFields; j++)
View Full Code Here

            colmd = fmd.getOrderMetaData().getColumnMetaData()[0];
        }
        else
        {
            // No column name so use default
            DatastoreIdentifier id =
                ((RDBMSIdentifierFactory)storeMgr.getIdentifierFactory()).newIndexFieldIdentifier();
            colmd = new ColumnMetaData(fmd, id.getIdentifier());
        }
        orderMapping = dba.getMapping(int.class, storeMgr); // JDO2 spec [18.5] order column is assumed to be "int"
        ColumnCreator.createIndexColumn(orderMapping, storeMgr, clr, this, colmd, pkRequired && !pkColsSpecified);
        if (JPOXLogger.DATASTORE.isDebugEnabled())
        {
View Full Code Here

TOP

Related Classes of org.jpox.store.mapped.DatastoreIdentifier

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.