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

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


            SpeedoCommonField sf,
            ClassMapping cm) throws PException, SpeedoException {
        String colName;
        String colType;
        RdbClassMultiMapping rcm = (RdbClassMultiMapping) cm;
        RdbTable t;
        RdbJoin join = null;
        if (sf == null) {
            //auto compute column name
            colName = pe.getName();
            colType = null;
View Full Code Here


            Class jclass,
            SpeedoCommonField sf,
            NameDef nd,
            NameDef tnd,
            SpeedoClass tclass) throws PException, SpeedoException {
        RdbTable table = rcm.getRdbTable();
        //Map the name def of the reference over new local columns
        if (nd.isFieldName()) {
            PrimitiveElement pe = (PrimitiveElement) jclass
                    .getTypedElement(nd.getFieldName());
            RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) table
                    .getPrimitiveElementMappingByCol(sf.columns[0].name);
            if (pem == null) {
                // create it
                table.createPrimitiveElementMapping(pe,
                        sf.columns[0].name, sf.columns[0].sqlType,
                        false);
            } else {
                //it already exists
                //remove the old hidden field
                ((Class) pe.getParent()).removeTypedElement(pe
                        .getName());
                //Use the existing one in the name def
                pe = (PrimitiveElement) pem.getLinkedMO();
                nd.setFieldName(pe.getName());
                if (pem.getType() == null) {
                    pem.setType(sf.columns[0].sqlType);
                }
            }
        } else {
            Map tndproj = tnd.getNameRef().getProjection();
            Iterator it = nd.getNameRef().getProjection().entrySet()
                    .iterator();
            while (it.hasNext()) {
                Map.Entry me = (Map.Entry) it.next();
                //find the field in the class used in by this name def
                PrimitiveElement pe = (PrimitiveElement) jclass
                        .getTypedElement((String) me.getValue());
                //find the pk column
                RdbPrimitiveElementMapping tpem = getPEMOfField(tclass,
                        (Mapping) rcm.getParent(),
                        (String) tndproj.get(me.getKey()));
                //find the fk column name
                SpeedoColumn fkCol = sf.getFKColumn(tpem.getName());
                //check if the fk column name is already used
                RdbPrimitiveElementMapping pem = (RdbPrimitiveElementMapping) table
                        .getPrimitiveElementMappingByCol(fkCol.name);
                if (pem == null) {
                    // create it
                    table.createPrimitiveElementMapping(pe, fkCol.name,
                            fkCol.sqlType, false);
                } else {
                    //it already exists
                    //remove the old hidden field
                    ((Class) pe.getParent()).removeTypedElement(pe.getName());
View Full Code Here

    public void createClassRefNameDefMapping(GenClassMapping gcm,
            NameDef nd,
            SpeedoField sf) throws PException, SpeedoException {
        RdbGenClassMapping rgcm = (RdbGenClassMapping) gcm;
        //Find the table (JORM Meta object)
        RdbTable table = rgcm.getRdbTable();
        GenClassRef gcr = (GenClassRef) gcm.getLinkedMO();
        if (nd.isFieldName()) {
            createPEMInGC(gcr.getHiddenField(nd.getFieldName()),
                    sf.columns[0], table, nd, null);
        } else {
View Full Code Here

    public void createGenClassIdentifierNameDefMapping(GenClassMapping gcm,
            NameDef nd, SpeedoField sf, MIBuilderHelper mibh)
            throws PException, SpeedoException {
        GenClassRef gcr = (GenClassRef) nd.getParent();
        RdbGenClassMapping rgcm = (RdbGenClassMapping) gcm;
        RdbTable table = rgcm.getRdbTable();
        if (nd.isFieldName()) {
            PrimitiveElement pe = gcr.getHiddenField(nd.getFieldName());
            SpeedoJoinColumn col = (SpeedoJoinColumn) sf.join.columns.get(0);
            createPEMInGC(pe, col.column, table, nd, null);
        } else {
View Full Code Here

            SpeedoField sf,
            Mapping mapping) throws PException, SpeedoException {
        RdbGenClassMapping rgcm = new RdbGenClassMapping("to-table", gcr,
                mapping);
        mapping.addGenClassMapping(gcr.getGenClassId(), rgcm);
        RdbTable t = null;
        if (gcr.isPrimitive()) {
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "The GCR field " + gcr.getName()
                        + " is mappeded over a dedicated table: "
                        + sf.join.extTable.name);
            }
            //Create the RdbTable for the Generic class
            rgcm.createRdbTable(sf.join.extTable.name);
        } else if (gcr.isClassRef()) {
            SpeedoField reverseField = sf.getReverseField();
            SpeedoClass tclass = sf.moClass.getSpeedoClassFromContext(
                    gcr.getClassRef().getMOClass().getFQName());
            Class targetClassJMO = tclass.jormclass;
            mapping.getClassMapping().addDependency(targetClassJMO.getFQName());
            switch (sf.relationType) {
            case SpeedoField.MANY_MANY_BI_RELATION:
                //Create the join table for the Generic class
                t = rgcm.createRdbTable(sf.join.extTable.name);
                if (reverseField.mappedByReversefield
                        || (reverseField.join != null
                                && reverseField.join.extTable != null
                                && t.getName().equalsIgnoreCase(reverseField.join.extTable.name))) {
                    //The MANY-MANY relation is mapped over the same join table
                  if (sf.name.compareToIgnoreCase(reverseField.name) < 0) {
                      // master side is not randomly choosen 
                      t.setColocatedMaster(true);
                  } else {
                      //write are done only on master side. The slave side
                      // reads only the generic class
                      t.setReadOnly(true);
                      t.setColocated(true);
                  }
                }
                if (logger.isLoggable(BasicLevel.DEBUG)) {
                    logger.log(BasicLevel.DEBUG, "Many-Many relation,"
                            + " join table: " + t.getName()
                            + (t.isColocated()?", colocated":"")
                            + (t.isColocatedMaster()?", master":"")
                            + (t.isReadOnly()?", readonly":"")
                            );
                }
                break;
            case SpeedoField.ONE_MANY_BI_RELATION:
                reverseField = sf.getReverseField();
              RdbClassMultiMapping trcm = (RdbClassMultiMapping) getClassMapping(
                    mapping, targetClassJMO);
              if (sf.mappedByReversefield) {
                  RdbTable tTable;
                  SpeedoTable table;
                  if (reverseField.join != null) {
                      table = reverseField.join.extTable;
                      tTable = trcm.getRdbExternalTable(table.name);
                  } else {
                      table = reverseField.moClass.mainTable;
                      tTable = trcm.getRdbTable();
                  }
                  t = rgcm.createRdbTable(table.name);
                  tTable.setColocated(true);
                    t.setColocated(true);
                  tTable.setColocatedMaster(true);
                    t.setColocatedMaster(false);
                  trcm.addDependency(sf.moClass.getFQName());
                  if (sf.isCoherentReverseField) {
                      //optimisation: the reverse field assumes the coherence.
                      // Then there is no need to write the generic class.
View Full Code Here

TOP

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

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.