CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java471
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java457
            columnNameToMD = new LinkedHashMap<SQLIdentifier, ColumnMetadata>();
            ResultSet rs = null;
            try {
                LOG.info( "Analyzing metadata for table {}", qTable );
                rs = dialect.getTableColumnMetadata( md, qTable );
                while ( rs.next() ) {
                    String column = rs.getString( 4 );
                    int sqlType = rs.getInt( 5 );
                    String sqlTypeName = rs.getString( 6 );
                    boolean isNullable = "YES".equals( rs.getString( 18 ) );
                    boolean isAutoincrement = false;
                    try {
                        isAutoincrement = "YES".equals( rs.getString( 23 ) );
                    } catch ( Throwable t ) {
                        // thanks to Larry E. for this
                    }
                    LOG.debug( "Found column '" + column + "', typeName: '" + sqlTypeName + "', typeCode: '" + sqlType
                               + "', isNullable: '" + isNullable + "', isAutoincrement:' " + isAutoincrement + "'" );

                    // type name ("geometry") works for PostGIS, MSSQL and Oracle
                    if ( sqlTypeName.toLowerCase().contains( "geometry" ) ) {
                        String srid = dialect.getUndefinedSrid();
                        ICRS crs = CRSManager.getCRSRef( "EPSG:4326", true );
                        CoordinateDimension dim = DIM_2;
                        GeometryPropertyType.GeometryType geomType = GeometryType.GEOMETRY;
                        Statement stmt = null;
                        ResultSet rs2 = null;
                        try {
                            stmt = conn.createStatement();
                            String sql = dialect.geometryMetadata( qTable, column, false );
                            rs2 = stmt.executeQuery( sql );
                            if ( rs2.next() ) {
                                if ( rs2.getInt( 2 ) != -1 ) {
                                    crs = CRSManager.lookup( "EPSG:" + rs2.getInt( 2 ), true );
                                    srid = "" + rs2.getInt( 2 );
                                } else {
                                    srid = dialect.getUndefinedSrid();
                                }
                                if ( rs2.getInt( 1 ) == 3 ) {
                                    dim = DIM_3;
                                }
                                geomType = getGeometryType( rs2.getString( 3 ) );
                                LOG.debug( "Derived geometry type: " + geomType + ", crs: " + crs + ", srid: " + srid
                                           + ", dim: " + dim + "" );
                            } else {
                                LOG.warn( "No metadata for geometry column '" + column
                                          + "' available in DB. Using defaults." );
                            }
                        } catch ( Exception e ) {
                            LOG.warn( "Unable to determine geometry column details: " + e.getMessage()
                                      + ". Using defaults.", e );
                        } finally {
                            JDBCUtils.close( rs2, stmt, null, LOG );
                        }
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java220
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java224
        for ( ColumnMetadata md : getColumns( table ).values() ) {
            if ( fidColumnNames.contains( new SQLIdentifier( md.column.toLowerCase() ) ) ) {
                LOG.debug( "Omitting column '" + md.column + "' from properties. Used in FIDMapping." );
                continue;
            }

            DBField dbField = new DBField( md.column );
            QName ptName = makeFullyQualified( new QName( md.column.toLowerCase() ), ftName.getPrefix(),
                                               ftName.getNamespaceURI() );
            if ( md.geomType == null ) {
                try {
                    BaseType type = BaseType.valueOf( md.sqlType );
                    PropertyType pt = new SimplePropertyType( ptName, 0, 1, type, null, null );
                    pts.add( pt );
                    ValueReference path = new ValueReference( ptName );
                    PrimitiveType primType = new PrimitiveType( type );
                    PrimitiveMapping mapping = new PrimitiveMapping( path, true, dbField, primType, null, null );
                    mappings.add( mapping );
                } catch ( IllegalArgumentException e ) {
                    LOG.warn( "Skipping column with type code '" + md.sqlType + "' from list of properties:"
                              + e.getMessage() );
                }
            } else {
                PropertyType pt = new GeometryPropertyType( ptName, 0, 1, null, null, md.geomType,
                                                            md.geometryParams.getDim(), INLINE );
                pts.add( pt );
                ValueReference path = new ValueReference( ptName );
                GeometryMapping mapping = new GeometryMapping( path, true, dbField, md.geomType, md.geometryParams,
                                                               null );
                mappings.add( mapping );
            }
        }

        FeatureType ft = new GenericFeatureType( ftName, pts, false );
        ftNameToFt.put( ftName, ft );

        FeatureTypeMapping ftMapping = new FeatureTypeMapping( ftName, table, fidMapping, mappings );
        ftNameToMapping.put( ftName, ftMapping );
    }

    private void process( TableName table, QName ftName, FIDMapping fidMapping,
                          List<JAXBElement<? extends AbstractParticleJAXB>> propDecls )
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java525
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java511
                        ColumnMetadata columnMd = new ColumnMetadata( column, sqlType, sqlTypeName, isNullable,
                                                                      geomType, dim, crs, srid );
                        columnNameToMD.put( new SQLIdentifier( column ), columnMd );
                    } else if ( sqlTypeName.toLowerCase().contains( "geography" ) ) {

                        LOG.warn( "Detected geography column. This is not fully supported yet. Expect bugs." );
                        String srid = dialect.getUndefinedSrid();
                        ICRS crs = CRSManager.getCRSRef( "EPSG:4326", true );
                        CoordinateDimension dim = DIM_2;
                        GeometryPropertyType.GeometryType geomType = GeometryType.GEOMETRY;
                        Statement stmt = null;
                        ResultSet rs2 = null;
                        try {
                            stmt = conn.createStatement();
                            String sql = dialect.geometryMetadata( qTable, column, true );
                            rs2 = stmt.executeQuery( sql );
                            if ( rs2.next() ) {
                                if ( rs2.getInt( 2 ) != -1 ) {
                                    crs = CRSManager.lookup( "EPSG:" + rs2.getInt( 2 ), true );
                                    srid = "" + rs2.getInt( 2 );
                                } else {
                                    srid = dialect.getUndefinedSrid();
                                }
                                if ( rs2.getInt( 1 ) == 3 ) {
                                    dim = DIM_3;
                                }
                                geomType = getGeometryType( rs2.getString( 3 ).toUpperCase() );
                                LOG.debug( "Derived geometry type (geography): " + geomType + ", crs: " + crs
                                           + ", srid: " + srid + ", dim: " + dim + "" );
                            } else {
                                LOG.warn( "No metadata for geography column '" + column
                                          + "' available in DB. Using defaults." );
                            }
                        } catch ( Exception e ) {
                            LOG.warn( "Unable to determine geography column details: " + e.getMessage()
                                      + ". Using defaults.", e );
                        } finally {
                            JDBCUtils.close( rs2, stmt, null, LOG );
                        }
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java374
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java360
            pt = new GeometryPropertyType( propName, minOccurs, maxOccurs, null, null, type, dim, INLINE );
            m = new GeometryMapping( path, minOccurs == 0, mapping, type, new GeometryStorageParams( crs, srid, dim ),
                                     jc );
        } else {
            LOG.warn( "Unhandled property declaration '" + propDecl.getClass() + "'. Skipping it." );
        }
        return new Pair<PropertyType, Mapping>( pt, m );
    }

    private FIDMapping buildFIDMapping( TableName table, QName ftName, FIDMappingJAXB config )
                            throws FeatureStoreException, SQLException {

        String prefix = config != null ? config.getPrefix() : null;
        if ( prefix == null ) {
            prefix = ftName.getPrefix().toUpperCase() + "_" + ftName.getLocalPart().toUpperCase() + "_";
        }

        // build FID columns / types from configuration
        List<Pair<SQLIdentifier, BaseType>> columns = new ArrayList<Pair<SQLIdentifier, BaseType>>();
        if ( config != null && config.getColumn() != null ) {
            for ( ColumnJAXB configColumn : config.getColumn() ) {
                SQLIdentifier columnName = new SQLIdentifier( configColumn.getName() );
                BaseType columnType = configColumn.getType() != null ? getPrimitiveType( configColumn.getType() )
                                                                    : null;
                if ( columnType == null ) {
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java410
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java396
                for ( ColumnMetadata md : getColumns( table ).values() ) {
                    if ( md.isAutoincrement ) {
                        BaseType columnType = BaseType.valueOf( md.sqlType );
                        columns.add( new Pair<SQLIdentifier, BaseType>( new SQLIdentifier( md.column ), columnType ) );
                        break;
                    }
                }
                if ( columns.isEmpty() ) {
                    throw new FeatureStoreException( "No autoincrement column in table '" + table
                                                     + "' found. Please specify column in FIDMapping manually." );
                }
            }
        } else {
            if ( columns.isEmpty() ) {
                throw new FeatureStoreException( "No FIDMapping columns for table '" + table
                                                 + "' specified. This is only possible for AutoIDGenerator." );
            }
        }

        return new FIDMapping( prefix, "_", columns, generator );
    }

    private QName makeFullyQualified( QName qName, String defaultPrefix, String defaultNamespace ) {
        String prefix = qName.getPrefix();
        String namespace = qName.getNamespaceURI();
        String localPart = qName.getLocalPart();
        if ( DEFAULT_NS_PREFIX.equals( prefix ) ) {
            prefix = defaultPrefix;
            namespace = defaultNamespace;
        }
        if ( "".equals( namespace ) ) {
            namespace = defaultNamespace;
        }
        return new QName( namespace, localPart, prefix );
    }

    private DatabaseMetaData getDBMetadata()
                            throws SQLException {
        if ( md == null ) {
            md = conn.getMetaData();
        }
        return md;
    }

    private ColumnMetadata getColumn( TableName qTable, SQLIdentifier columnName )
FileLine
org/deegree/feature/persistence/mapping/antlr/FMLLexer.java135
org/deegree/feature/persistence/mapping/antlr/FMLLexer.java356
                case '-':
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                case 'A':
                case 'B':
                case 'C':
                case 'D':
                case 'E':
                case 'F':
                case 'G':
                case 'H':
                case 'I':
                case 'J':
                case 'K':
                case 'L':
                case 'M':
                case 'N':
                case 'O':
                case 'P':
                case 'Q':
                case 'R':
                case 'S':
                case 'T':
                case 'U':
                case 'V':
                case 'W':
                case 'X':
                case 'Y':
                case 'Z':
                case '_':
                case 'a':
                case 'b':
                case 'c':
                case 'd':
                case 'e':
                case 'f':
                case 'g':
                case 'h':
                case 'i':
                case 'j':
                case 'k':
                case 'l':
                case 'm':
                case 'n':
                case 'o':
                case 'p':
                case 'q':
                case 'r':
                case 's':
                case 't':
                case 'u':
                case 'v':
                case 'w':
                case 'x':
                case 'y':
                case 'z':
                    {
FileLine
org/deegree/feature/persistence/sql/SQLFeatureStore.java849
org/deegree/feature/persistence/sql/SQLFeatureStore.java1253
            sql.append( " WHERE " );
            sql.append( alias );
            sql.append( "." );
            sql.append( blobMapping.getTypeColumn() );
            sql.append( "=?" );
            if ( wb != null ) {
                sql.append( " AND " );
                sql.append( wb.getWhere().getSQL() );
            }
            LOG.debug( "SQL: {}", sql );
            long begin = System.currentTimeMillis();
            stmt = conn.prepareStatement( sql.toString() );
            LOG.debug( "Preparing SELECT took {} [ms] ", System.currentTimeMillis() - begin );

            int i = 1;
            stmt.setShort( i++, getSchema().getFtId( ftName ) );
            if ( wb != null ) {
                for ( SQLArgument o : wb.getWhere().getArguments() ) {
                    o.setArgument( stmt, i++ );
                }
            }

            begin = System.currentTimeMillis();
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java175
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java179
    private void process( FeatureTypeMappingJAXB ftDecl )
                            throws SQLException, FeatureStoreException {

        if ( ftDecl.getTable() == null || ftDecl.getTable().isEmpty() ) {
            String msg = "Feature type element without or with empty table attribute.";
            throw new FeatureStoreException( msg );
        }

        TableName table = new TableName( ftDecl.getTable() );
        LOG.debug( "Processing feature type mapping for table '" + table + "'." );
        if ( getColumns( table ).isEmpty() ) {
            throw new FeatureStoreException( "No table with name '" + table + "' exists (or no columns defined)." );
        }

        QName ftName = ftDecl.getName();
        if ( ftName == null ) {
            LOG.debug( "Using table name for feature type." );
            ftName = new QName( table.getTable() );
        }
        ftName = makeFullyQualified( ftName, "app", "http://www.deegree.org/app" );
        LOG.debug( "Feature type name: '" + ftName + "'." );

        FIDMapping fidMapping = buildFIDMapping( table, ftName, ftDecl.getFIDMapping() );

        List<JAXBElement<? extends AbstractParticleJAXB>> propDecls = ftDecl.getAbstractParticle();
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java147
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java151
            for ( FeatureTypeMappingJAXB ftDecl : ftDecls ) {
                process( ftDecl );
            }
        } finally {
            JDBCUtils.close( conn );
        }
        this.deleteCascadingByDB = deleteCascadingByDB;
    }

    /**
     * Returns the {@link MappedAppSchema} derived from configuration / tables.
     * 
     * @return mapped application schema, never <code>null</code>
     */
    public MappedAppSchema getMappedSchema() {
        FeatureType[] fts = ftNameToFt.values().toArray( new FeatureType[ftNameToFt.size()] );
        FeatureTypeMapping[] ftMappings = ftNameToMapping.values().toArray( new FeatureTypeMapping[ftNameToMapping.size()] );
        Map<FeatureType, FeatureType> ftToSuperFt = null;
        Map<String, String> prefixToNs = null;
        GMLSchemaInfoSet xsModel = null;
        // TODO
        GeometryStorageParams geometryParams = new GeometryStorageParams( CRSManager.getCRSRef( "EPSG:4326" ),
                                                                          dialect.getUndefinedSrid(),
                                                                          CoordinateDimension.DIM_2 );
        return new MappedAppSchema( fts, ftToSuperFt, prefixToNs, xsModel, ftMappings, null, null, geometryParams,
                                    deleteCascadingByDB, null, null, null );
    }

    private void process( FeatureTypeMappingJAXB ftDecl )
FileLine
org/deegree/feature/persistence/sql/ddl/MSSQLDDLCreator.java152
org/deegree/feature/persistence/sql/ddl/OracleDDLCreator.java231
            sql.append( " geometry" );
            ddls.addAll( getGeometryCreate( mapping, (DBField) me, table ) );
        } else {
            LOG.info( "Skipping geometry mapping -- not mapped to a db field. " );
        }
    }

    @Override
    protected void featureMappingSnippet( StringBuffer sql, FeatureMapping mapping ) {
        SQLIdentifier col = mapping.getJoinedTable().get( mapping.getJoinedTable().size() - 1 ).getFromColumns().get( 0 );
        if ( col != null ) {
            sql.append( ",\n    " );
            sql.append( col );
            sql.append( " varchar(2000)" );
        }
        MappingExpression hrefMe = mapping.getHrefMapping();
        if ( hrefMe instanceof DBField ) {
            sql.append( ",\n    " );
            sql.append( ( (DBField) hrefMe ).getColumn() );
            sql.append( " varchar(2000)" );
        }
    }
FileLine
org/deegree/feature/persistence/sql/ddl/MSSQLDDLCreator.java130
org/deegree/feature/persistence/sql/ddl/OracleDDLCreator.java209
    }

    @Override
    protected void primitiveMappingSnippet( StringBuffer sql, PrimitiveMapping mapping ) {
        MappingExpression me = mapping.getMapping();
        if ( me instanceof DBField ) {
            DBField dbField = (DBField) me;
            sql.append( ",\n    " );
            sql.append( dbField.getColumn() );
            sql.append( " " );
            sql.append( getDBType( mapping.getType().getBaseType() ) );
        }
    }

    @Override
    protected void geometryMappingSnippet( StringBuffer sql, GeometryMapping mapping, List<StringBuffer> ddls,
                                           TableName table ) {
        MappingExpression me = mapping.getMapping();
        if ( me instanceof DBField ) {
            DBField dbField = (DBField) me;
            sql.append( ",\n    " );
            sql.append( dbField.getColumn() );
            sql.append( " geometry" );
FileLine
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTable.java199
org/deegree/feature/persistence/sql/config/MappedSchemaBuilderTableOld.java203
        List<JAXBElement<? extends AbstractParticleJAXB>> propDecls = ftDecl.getAbstractParticle();
        if ( propDecls != null && !propDecls.isEmpty() ) {
            process( table, ftName, fidMapping, propDecls );
        } else {
            process( table, ftName, fidMapping );
        }
    }

    private void process( TableName table, QName ftName, FIDMapping fidMapping )
                            throws SQLException {

        LOG.debug( "Deriving properties and mapping for feature type '" + ftName + "' from table '" + table + "'" );

        List<PropertyType> pts = new ArrayList<PropertyType>();
        List<Mapping> mappings = new ArrayList<Mapping>();

        Set<SQLIdentifier> fidColumnNames = new HashSet<SQLIdentifier>();
        for ( Pair<SQLIdentifier, BaseType> column : fidMapping.getColumns() ) {
            fidColumnNames.add( column.first );
        }

        for ( ColumnMetadata md : getColumns( table ).values() ) {
FileLine
org/deegree/feature/persistence/sql/mapper/XPathSchemaWalker.java93
org/deegree/feature/persistence/sql/mapper/XPathSchemaWalker.java145
    public Pair<XSElementDeclaration, Boolean> getTargetElement( Pair<XSElementDeclaration, Boolean> context,
                                                                 ValueReference propName ) {

        Expr path = propName.getAsXPath();
        if ( !( path instanceof LocationPath ) ) {
            throw new IllegalArgumentException( "XPath '" + propName + "' does not denote a location path." );
        }

        Pair<XSElementDeclaration, Boolean> currentEl = context;
        for ( Object o : ( (LocationPath) path ).getSteps() ) {
            if ( o instanceof NameStep ) {
                NameStep step = (NameStep) o;
                if ( step.getAxis() == Axis.CHILD ) {
                    // TODO check predicates
                    QName qName = getQName( step );
                    int num = getNumber( step );
                    currentEl = getTargetElement( currentEl, qName, num );
                    if ( currentEl == null ) {
                        throw new IllegalArgumentException( "Unable to match XPath '" + propName.getAsText()
FileLine
org/deegree/feature/persistence/sql/rules/FeatureBuilderRelational.java500
org/deegree/feature/persistence/sql/rules/FeatureBuilderRelational.java597
                        XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) cm.getElementDecl().getTypeDefinition();
                        XSObjectList attrUses = complexType.getAttributeUses();
                        for ( int i = 0; i < attrUses.getLength(); i++ ) {
                            XSAttributeUse attrUse = (XSAttributeUse) attrUses.item( i );
                            if ( attrUse.getRequired() ) {
                                QName attrName = null;
                                XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration();
                                if ( attrDecl.getNamespace() == null || attrDecl.getNamespace().isEmpty() ) {
                                    attrName = new QName( attrDecl.getName() );
                                } else {
                                    attrName = new QName( attrDecl.getNamespace(), attrDecl.getName() );
                                }
                                PrimitiveValue attrValue = attrs.get( attrName );
                                if ( attrValue == null ) {
FileLine
org/deegree/feature/persistence/sql/insert/InsertRowManager.java176
org/deegree/feature/persistence/sql/insert/InsertRowManager.java228
            LOG.debug( "Built rows for feature '" + feature.getId() + "': " + allRows.size() );

            for ( InsertRow insertRow : allRows ) {
                if ( !insertRow.hasParents() ) {
                    rootRows.add( insertRow );
                }
            }

            LOG.debug( "Before heap run: uninserted rows: " + delayedRows.size() + ", root rows: " + rootRows.size() );
            processHeap();
            LOG.debug( "After heap run: uninserted rows: " + delayedRows.size() + ", root rows: " + rootRows.size() );

        } catch ( Throwable t ) {
            LOG.debug( t.getMessage(), t );
            throw new FeatureStoreException( t.getMessage(), t );
        }
        return featureRow;
    }
FileLine
org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java552
org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java610
            if ( attrDecl.getNamespace() != null ) {
                attrName = new QName( attrDecl.getNamespace(), attrDecl.getName() );
            }
            MappingContext attrMc = mcManager.mapOneToOneAttribute( mc, attrName );
            // TODO
            NamespaceContext nsContext = null;
            ValueReference path = new ValueReference( "@" + getName( attrName ), nsContext );
            DBField dbField = new DBField( attrMc.getTable(), attrMc.getColumn() );
            PrimitiveType pt = new PrimitiveType( attrDecl.getTypeDefinition() );
            particles.add( new PrimitiveMapping( path, !attrUse.getRequired(), dbField, pt, null, null ) );
        }

        // xsi:nil attribute
        if ( isNillable ) {
FileLine
org/deegree/feature/persistence/sql/SQLFeatureStore.java1285
org/deegree/feature/persistence/sql/SQLFeatureStore.java1411
                for ( SQLArgument o : wb.getWhere().getArguments() ) {
                    o.setArgument( stmt, i++ );
                }
            }
            // }
            // if ( wb != null && wb.getWhere() != null ) {
            // for ( SQLArgument o : wb.getWhere().getArguments() ) {
            // o.setArgument( stmt, i++ );
            // }
            // }
            // if ( wb != null && wb.getOrderBy() != null ) {
            // for ( SQLArgument o : wb.getOrderBy().getArguments() ) {
            // o.setArgument( stmt, i++ );
            // }
            // }

            begin = System.currentTimeMillis();
            stmt.setFetchSize( fetchSize );
            rs = stmt.executeQuery();
            LOG.debug( "Executing SELECT took {} [ms] ", System.currentTimeMillis() - begin );

            result = new IteratorFeatureInputStream( new FeatureResultSetIterator( builder, rs, conn, stmt ) );
        } catch ( Exception e ) {
            close( rs, stmt, conn, LOG );
            String msg = "Error performing query by operator filter: " + e.getMessage();
            LOG.error( msg, e );
            throw new FeatureStoreException( msg, e );
        }

        if ( filter != null ) {
FileLine
org/deegree/feature/persistence/sql/ddl/MSSQLDDLCreator.java130
org/deegree/feature/persistence/sql/ddl/OracleDDLCreator.java209
org/deegree/feature/persistence/sql/ddl/PostGISDDLCreator.java128
    }

    @Override
    protected void primitiveMappingSnippet( StringBuffer sql, PrimitiveMapping mapping ) {
        MappingExpression me = mapping.getMapping();
        if ( me instanceof DBField ) {
            DBField dbField = (DBField) me;
            sql.append( ",\n    " );
            sql.append( dbField.getColumn() );
            sql.append( " " );
            sql.append( getDBType( mapping.getType().getBaseType() ) );
        }
    }

    @Override
    protected void geometryMappingSnippet( StringBuffer sql, GeometryMapping mapping, List<StringBuffer> ddls,
                                           TableName table ) {
        MappingExpression me = mapping.getMapping();
        if ( me instanceof DBField ) {
FileLine
org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java350
org/deegree/feature/persistence/sql/mapper/AppSchemaMapper.java367
        LOG.debug( "Mapping simple property '" + pt.getName() + "'" );
        ValueReference path = getPropName( pt.getName() );
        MappingContext propMc = null;
        List<TableJoin> jc = null;
        MappingExpression mapping = null;
        if ( pt.getMaxOccurs() == 1 ) {
            propMc = mcManager.mapOneToOneElement( mc, pt.getName() );
            mapping = new DBField( propMc.getColumn() );
        } else {
            propMc = mcManager.mapOneToManyElements( mc, pt.getName() );
            jc = generateJoinChain( mc, propMc );
            mapping = new DBField( "value" );
        }
        return new PrimitiveMapping( path, false, mapping, pt.getPrimitiveType(), jc, null );