Package org.apache.openjpa.jdbc.meta

Examples of org.apache.openjpa.jdbc.meta.DiscriminatorMappingInfo


        ClassMapping cls = disc.getClassMapping();
        if (cls.getJoinablePCSuperclassMapping() != null
            || cls.getEmbeddingMetaData() != null)
            throw new MetaDataException(_loc.get("not-base-disc", cls));

        DiscriminatorMappingInfo info = disc.getMappingInfo();
        info.assertNoJoin(disc, true);
        info.assertNoForeignKey(disc, !adapt);
        info.assertNoUnique(disc, false);

        Column tmplate = new Column();
        tmplate.setJavaType(getJavaType());
        tmplate.setName("typ");

        Column[] cols = info.getColumns(disc, new Column[]{ tmplate }, adapt);
        disc.setColumns(cols);
        disc.setColumnIO(info.getColumnIO());

        Index idx = info.getIndex(disc, cols, adapt);
        disc.setIndex(idx);
    }
View Full Code Here


    @Override
    protected void serializeInheritanceContent(ClassMetaData mapping) {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        DiscriminatorMappingInfo dinfo = cls.getDiscriminator()
            .getMappingInfo();
        String strat = info.getHierarchyStrategy();
        if (null == strat)
            return;
        String itypecls = Strings.getClassName(InheritanceType.class);
        AnnotationBuilder abInheritance =
            addAnnotation(Inheritance.class, mapping);
        if (FlatClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".SINGLE_TABLE");
        else if (VerticalClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".JOINED");
        else if (FullClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".TABLE_PER_CLASS");
        if (dinfo.getValue() != null) {
            AnnotationBuilder abDiscVal =
                addAnnotation(DiscriminatorValue.class, mapping);
            abDiscVal.add(null, dinfo.getValue());
        }
        AnnotationBuilder abDiscCol =
            addAnnotation(DiscriminatorColumn.class, mapping);
        serializeColumns(dinfo, ColType.DISC, null, abDiscCol, null);
    }
View Full Code Here

    @Override
    protected void serializeInheritanceContent(ClassMetaData mapping)
        throws SAXException {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        DiscriminatorMappingInfo dinfo = cls.getDiscriminator()
            .getMappingInfo();
        String strat = info.getHierarchyStrategy();
        if (FlatClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "SINGLE_TABLE");
        else if (VerticalClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "JOINED");
        else if (FullClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "TABLE_PER_CLASS");
        if (strat != null) {
            startElement("inheritance");
            endElement("inheritance");
        }
        if (dinfo.getValue() != null) {
            startElement("discriminator-value");
            addText(dinfo.getValue());
            endElement("discriminator-value");
        }
        serializeColumns(dinfo, ColType.DISC, null);
    }
View Full Code Here

        if (_supJoinCols != null)
            cm.getMappingInfo().setColumns(_supJoinCols);

        if (_discCol != null) {
            DiscriminatorMappingInfo dinfo = cm.getDiscriminator()
                    .getMappingInfo();
            switch (_discType) {
                case CHAR:
                    _discCol.setJavaType(JavaTypes.CHAR);
                    cm.getDiscriminator().setJavaType(JavaTypes.CHAR);
                    break;
                case INTEGER:
                    _discCol.setJavaType(JavaTypes.INT);
                    cm.getDiscriminator().setJavaType(JavaTypes.INT);
                    break;
                default:
                    _discCol.setJavaType(JavaTypes.STRING);
                    cm.getDiscriminator().setJavaType(JavaTypes.STRING);
                    break;
            }
            dinfo.setColumns(Arrays.asList(new Column[]{ _discCol }));
        }
        clearClassInfo();
    }
View Full Code Here

        if (_supJoinCols != null)
            cm.getMappingInfo().setColumns(_supJoinCols);

        if (_discCol != null) {
            DiscriminatorMappingInfo dinfo = cm.getDiscriminator()
                    .getMappingInfo();
            switch (_discType) {
                case CHAR:
                    _discCol.setJavaType(JavaTypes.CHAR);
                    cm.getDiscriminator().setJavaType(JavaTypes.CHAR);
                    break;
                case INTEGER:
                    _discCol.setJavaType(JavaTypes.INT);
                    cm.getDiscriminator().setJavaType(JavaTypes.INT);
                    break;
                default:
                    _discCol.setJavaType(JavaTypes.STRING);
                    cm.getDiscriminator().setJavaType(JavaTypes.STRING);
                    break;
            }
            dinfo.setColumns(Arrays.asList(new Column[]{ _discCol }));
        }
        clearClassInfo();
    }
View Full Code Here

        if (_supJoinCols != null)
            cm.getMappingInfo().setColumns(_supJoinCols);

        if (_discCol != null) {
            DiscriminatorMappingInfo dinfo = cm.getDiscriminator()
                    .getMappingInfo();
            switch (_discType) {
                case CHAR:
                    _discCol.setJavaType(JavaTypes.CHAR);
                    cm.getDiscriminator().setJavaType(JavaTypes.CHAR);
                    break;
                case INTEGER:
                    _discCol.setJavaType(JavaTypes.INT);
                    cm.getDiscriminator().setJavaType(JavaTypes.INT);
                    break;
                default:
                    _discCol.setJavaType(JavaTypes.STRING);
                    cm.getDiscriminator().setJavaType(JavaTypes.STRING);
                    break;
            }
            dinfo.setColumns(Arrays.asList(new Column[]{ _discCol }));
        }
        clearClassInfo();
    }
View Full Code Here

    @Override
    protected void serializeInheritanceContent(ClassMetaData mapping)
        throws SAXException {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        DiscriminatorMappingInfo dinfo = cls.getDiscriminator()
            .getMappingInfo();
        String strat = info.getHierarchyStrategy();
        if (FlatClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "SINGLE_TABLE");
        else if (VerticalClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "JOINED");
        else if (FullClassStrategy.ALIAS.equals(strat))
            addAttribute("strategy", "TABLE_PER_CLASS");
        if (strat != null) {
            startElement("inheritance");
            endElement("inheritance");
        }
        if (dinfo.getValue() != null) {
            startElement("discriminator-value");
            addText(dinfo.getValue());
            endElement("discriminator-value");
        }
        serializeColumns(dinfo, ColType.DISC, null);
    }
View Full Code Here

        if (_supJoinCols != null)
            cm.getMappingInfo().setColumns(_supJoinCols);

        if (_discCol != null) {
            DiscriminatorMappingInfo dinfo = cm.getDiscriminator()
                    .getMappingInfo();
            switch (_discType) {
                case CHAR:
                    _discCol.setJavaType(JavaTypes.CHAR);
                    cm.getDiscriminator().setJavaType(JavaTypes.CHAR);
                    break;
                case INTEGER:
                    _discCol.setJavaType(JavaTypes.INT);
                    cm.getDiscriminator().setJavaType(JavaTypes.INT);
                    break;
                default:
                    _discCol.setJavaType(JavaTypes.STRING);
                    cm.getDiscriminator().setJavaType(JavaTypes.STRING);
                    break;
            }
            dinfo.setColumns(Arrays.asList(new Column[]{ _discCol }));
        }
        clearClassInfo();
    }
View Full Code Here

    @Override
    protected void serializeInheritanceContent(ClassMetaData mapping) {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        DiscriminatorMappingInfo dinfo = cls.getDiscriminator()
            .getMappingInfo();
        String strat = info.getHierarchyStrategy();
        if (null == strat)
            return;
        String itypecls = Strings.getClassName(InheritanceType.class);
        AnnotationBuilder abInheritance =
            addAnnotation(Inheritance.class, mapping);
        if (FlatClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".SINGLE_TABLE");
        else if (VerticalClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".JOINED");
        else if (FullClassStrategy.ALIAS.equals(strat))
            abInheritance.add("strategy", itypecls + ".TABLE_PER_CLASS");
        if (dinfo.getValue() != null) {
            AnnotationBuilder abDiscVal =
                addAnnotation(DiscriminatorValue.class, mapping);
            abDiscVal.add(null, dinfo.getValue());
        }
        AnnotationBuilder abDiscCol =
            addAnnotation(DiscriminatorColumn.class, mapping);
        serializeColumns(dinfo, ColType.DISC, null, abDiscCol, null);
    }
View Full Code Here

        ClassMapping cls = disc.getClassMapping();
        if (cls.getJoinablePCSuperclassMapping() != null
            || cls.getEmbeddingMetaData() != null)
            throw new MetaDataException(_loc.get("not-base-disc", cls));

        DiscriminatorMappingInfo info = disc.getMappingInfo();
        info.assertNoJoin(disc, true);
        info.assertNoForeignKey(disc, !adapt);
        info.assertNoUnique(disc, false);

        Column tmplate = new Column();
        tmplate.setJavaType(getJavaType());
        DBDictionary dict = cls.getMappingRepository().getDBDictionary();
        DBIdentifier typName = DBIdentifier.newColumn("typ", dict != null ? dict.delimitAll() : false);
        tmplate.setIdentifier(typName);

        Column[] cols = info.getColumns(disc, new Column[]{ tmplate }, adapt);
        disc.setColumns(cols);
        disc.setColumnIO(info.getColumnIO());

        Index idx = info.getIndex(disc, cols, adapt);
        disc.setIndex(idx);
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.meta.DiscriminatorMappingInfo

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.