Package org.datanucleus.store.mapped.mapping

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


                                CorrespondentColumnsMapper correspondentColumnsMapping =
                                    new CorrespondentColumnsMapper(colmdContainer, ownerIdMapping, true);
                                int countIdFields = ownerIdMapping.getNumberOfDatastoreMappings();
                                for (int i=0; i<countIdFields; i++)
                                {
                                    DatastoreMapping refDatastoreMapping = ownerIdMapping.getDatastoreMapping(i);
                                    JavaTypeMapping mapping = storeMgr.getMappingManager().getMapping(refDatastoreMapping.getJavaTypeMapping().getJavaType());
                                    ColumnMetaData colmd = correspondentColumnsMapping.getColumnMetaDataByIdentifier(((Column)refDatastoreMapping.getDatastoreField()).getIdentifier());
                                    if (colmd == null)
                                    {
                                        throw new NucleusUserException(LOCALISER.msg("057035",
                                            ((Column)refDatastoreMapping.getDatastoreField()).getIdentifier(), toString())).setFatal();
                                    }

                                    DatastoreIdentifier identifier = null;
                                    IdentifierFactory idFactory = storeMgr.getIdentifierFactory();
                                    if (colmd.getName() == null || colmd.getName().length() < 1)
                                    {
                                        // No user provided name so generate one
                                        identifier = idFactory.newForeignKeyFieldIdentifier(ownerFmd,
                                            null, refDatastoreMapping.getDatastoreField().getIdentifier(),
                                            storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(mapping.getJavaType()),
                                            FieldRole.ROLE_OWNER);
                                    }
                                    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.getAllowsNull() == null) ||
                                            (colmd != null && colmd.getAllowsNull() != null && colmd.isAllowsNull()))
                                    {
                                        // User either wants it nullable, or haven't specified anything, so make it nullable
                                        refColumn.setNullable();
                                    }

                                    fkMapping.addDatastoreMapping(getStoreManager().getMappingManager().createDatastoreMapping(mapping, refColumn, refDatastoreMapping.getJavaTypeMapping().getJavaType().getName()));
                                    ((PersistableMapping)fkMapping).addJavaTypeMapping(mapping);
                                }
                            }
                            catch (DuplicateDatastoreFieldException dce)
                            {
View Full Code Here


                }
            }
            datastoreMappingClass = getDatastoreMappingClass(mmd.getFullFieldName(), javaType, jdbcType, sqlType, clr);
        }

        DatastoreMapping datastoreMapping = DatastoreMappingFactory.createMapping(datastoreMappingClass, mapping, storeMgr, column);
        if (column != null)
        {
            column.setDatastoreMapping(datastoreMapping);
        }
        return datastoreMapping;
View Full Code Here

            jdbcType = col.getColumnMetaData().getJdbcType();
            sqlType = col.getColumnMetaData().getSqlType();
        }
        Class datastoreMappingClass = getDatastoreMappingClass(null, javaType, jdbcType, sqlType, clr);

        DatastoreMapping datastoreMapping = DatastoreMappingFactory.createMapping(datastoreMappingClass, mapping, storeMgr, column);
        if (column != null)
        {
            column.setDatastoreMapping(datastoreMapping);
        }
        return datastoreMapping;
View Full Code Here

        PersistableMapping idMapping = (PersistableMapping)table.getIdMapping();
        String[] idColNames = new String[idMapping.getNumberOfDatastoreMappings()];
        boolean[] idColMissing = new boolean[idMapping.getNumberOfDatastoreMappings()];
        for (int i=0;i<idMapping.getNumberOfDatastoreMappings();i++)
        {
            DatastoreMapping m = idMapping.getDatastoreMapping(i);
            idColNames[i] = m.getDatastoreField().getIdentifier().toString();
            idColMissing[i] = true;
        }

        // Generate discriminator/version information for later checking they are present
        String discriminatorColName = table.getDiscriminatorMapping(false) != null ?
View Full Code Here

                PersistableMapping idMapping = (PersistableMapping)table.getIdMapping();
                String[] idColNames = new String[idMapping.getNumberOfDatastoreMappings()];
                boolean[] idColMissing = new boolean[idMapping.getNumberOfDatastoreMappings()];
                for (int i=0;i<idMapping.getNumberOfDatastoreMappings();i++)
                {
                    DatastoreMapping m = idMapping.getDatastoreMapping(i);
                    idColNames[i] = m.getDatastoreField().getIdentifier().toString();
                    idColMissing[i] = true;
                }

                // Generate discriminator/version information for later checking they are present
                String discriminatorColName = table.getDiscriminatorMapping(false) != null ?
View Full Code Here

        {
            return expr.eq(this);
        }
        else if (expr instanceof BooleanExpression)
        {
            DatastoreMapping datastoreMapping = mapping.getDatastoreMapping(0);
            if (datastoreMapping.isStringBased())
            {
                // Persisted using "Y", "N"
                return new BooleanExpression(new CharacterExpression(stmt, table, mapping),
                    Expression.OP_EQ,
                    new CharacterExpression(stmt, expr.table, expr.mapping));
            }
            else if ((datastoreMapping.isBitBased() || datastoreMapping.isIntegerBased()) &&
                    !stmt.getDatabaseAdapter().supportsOption(DatastoreAdapter.BIT_IS_REALLY_BOOLEAN))
            {
                // Persisted using "1", "0"
                return new BooleanExpression(new NumericExpression(stmt, table, mapping),
                    Expression.OP_EQ,
View Full Code Here

        {
            return expr.ne(this);
        }
        else if (expr instanceof BooleanExpression)
        {
            DatastoreMapping datastoreMapping = mapping.getDatastoreMapping(0);
            if (datastoreMapping.isStringBased())
            {
                // Persisted using "Y", "N"
                return new BooleanExpression(new CharacterExpression(stmt, table, mapping),
                    Expression.OP_NOTEQ,
                    new CharacterExpression(stmt, expr.table, expr.mapping));
            }
            else if ((datastoreMapping.isBitBased() || datastoreMapping.isIntegerBased()) &&
                    !stmt.getDatabaseAdapter().supportsOption(DatastoreAdapter.BIT_IS_REALLY_BOOLEAN))
            {
                // Persisted using "1", "0"
                return new BooleanExpression(new NumericExpression(stmt, table, mapping),
                    Expression.OP_NOTEQ,
View Full Code Here

        }
    }

    public BooleanExpression in(SQLExpression expr, boolean not)
    {
        DatastoreMapping datastoreMapping = mapping.getDatastoreMapping(0);
        if (datastoreMapping.isStringBased())
        {
            return new BooleanExpression(new CharacterExpression(stmt, table, mapping),
                (not ? Expression.OP_NOTIN : Expression.OP_IN), expr);
        }
        else
View Full Code Here

            BooleanLiteral exprLit = (BooleanLiteral)expr;
            return new BooleanLiteral(stmt, mapping, value == exprLit.value);
        }
        else if (expr instanceof BooleanExpression)
        {
            DatastoreMapping datastoreMapping = expr.mapping.getDatastoreMapping(0);
            if (datastoreMapping.isStringBased())
            {
                // Expression uses "Y", "N"
                return new BooleanExpression(expr, Expression.OP_EQ,
                    new CharacterLiteral(stmt, mapping, value ? "Y" : "N", null));
            }
            else if ((datastoreMapping.isBitBased() || datastoreMapping.isIntegerBased()) &&
                    !stmt.getDatabaseAdapter().supportsOption(DatastoreAdapter.BIT_IS_REALLY_BOOLEAN))
            {
                // Expression uses "1", "0"
                return new BooleanExpression(expr, Expression.OP_EQ,
                    new IntegerLiteral(stmt, mapping, value ? 1 : 0, null));
View Full Code Here

            BooleanLiteral exprLit = (BooleanLiteral)expr;
            return new BooleanLiteral(stmt, mapping, value != exprLit.value);
        }
        else if (expr instanceof BooleanExpression)
        {
            DatastoreMapping datastoreMapping = expr.mapping.getDatastoreMapping(0);
            if (datastoreMapping.isStringBased())
            {
                // Expression uses "Y", "N"
                return new BooleanExpression(expr, Expression.OP_NOTEQ,
                    new CharacterLiteral(stmt, mapping, value ? "Y" : "N", null));
            }
            else if ((datastoreMapping.isBitBased() || datastoreMapping.isIntegerBased()) &&
                    !stmt.getDatabaseAdapter().supportsOption(DatastoreAdapter.BIT_IS_REALLY_BOOLEAN))
            {
                // Expression uses "1", "0"
                return new BooleanExpression(expr, Expression.OP_NOTEQ,
                    new IntegerLiteral(stmt, mapping, value ? 1 : 0, null));
View Full Code Here

TOP

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

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.