Package org.objectweb.jorm.mapper.rdb.metainfo

Examples of org.objectweb.jorm.mapper.rdb.metainfo.RdbExternalTable


            rcm.createRdbTable(sc.mainTable.name);
        }
        //Build JORM meta objects for the secondary (external) tables
        if (sc.joinToExtTables != null) {
            for (int i = 0; i < sc.joinToExtTables.length; i++) {
                RdbExternalTable extTable = rcm
                        .createRdbExternalTable(sc.joinToExtTables[i].extTable.name);
                RdbJoin join = extTable.createRdbJoin("_" + i);
                if (debug) {
                    logger.log(BasicLevel.DEBUG, "define external table '"
                            + sc.joinToExtTables[i].extTable.name
                            + "' for the class '" + sc.getFQName() + "'.");
                }
View Full Code Here


            SpeedoCommonField sf,
            NameDef nd,
            RdbClassMultiMapping trcm,
            NameDef tnd,
            SpeedoClass tclass) throws PException, SpeedoException {
        RdbExternalTable exttable = rcm.createRdbExternalTable(sf.join.extTable.name);
        if (sf.join.extTable.name.equals(tclass.mainTable.name)) {
            // The external table is the table of the targeted class
            exttable.setColocated(true);
            trcm.getRdbTable().setColocated(true);
            trcm.getRdbTable().setColocatedMaster(true);
            trcm.addDependency(sf.moClass.getFQName());
            rcm.addDependency(tclass.getFQName());
            //optimisation: if there is a reverse field then we suppose
            // that the user will do the coherence.
            if (sf instanceof SpeedoField) {
                exttable.setReadOnly(((SpeedoField) sf).isCoherentReverseField);
            } else if (sf instanceof SpeedoInheritedField) {
                exttable.setReadOnly(((SpeedoInheritedField) sf).inheritedField.isCoherentReverseField);
            }
            exttable.setColocated(true);
            exttable.setColocatedMaster(false);
        }

        //Define the join to the external table
        RdbJoin j = exttable.createRdbJoin(sf.name);
        for (Iterator fkColIt = sf.join.columns.iterator(); fkColIt
                .hasNext();) {
            SpeedoJoinColumn jc = (SpeedoJoinColumn) fkColIt.next();
            j.addJoinColumnNames(jc.targetColumn, jc.column.name);
        }
        // map the name def over pk field of the referenced class
        if (tnd.isFieldName()) {
            RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) trcm
                    .getPrimitiveElementMapping(tnd.getFieldName(), true);
            PrimitiveElement pe = (PrimitiveElement) jclass
                    .getTypedElement(nd.getFieldName());
            exttable.createPrimitiveElementMapping(pe, pem.getName(),
                    null, false, j);
        } else {
            Map tclassndproj = tnd.getNameRef().getProjection();
            Iterator it = nd.getNameRef().getProjection().entrySet()
                    .iterator();
            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();
                PrimitiveElement pe = (PrimitiveElement) jclass
                        .getTypedElement((String) me.getValue());
                RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping)
                  trcm.getPrimitiveElementMapping(
                          (String) tclassndproj.get(me.getKey()), true);
                exttable.createPrimitiveElementMapping(pe, pem.getName(), null, false, j);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.objectweb.jorm.mapper.rdb.metainfo.RdbExternalTable

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.