Examples of AnnotationBuilder


Examples of org.apache.openjpa.persistence.AnnotationBuilder

     * Creates an an annotation builder for the specified class metadata
     * and adds it to list of builders.
     */
    protected AnnotationBuilder addAnnotation(
        Class<? extends Annotation> annType, QueryResultMapping meta) {
        AnnotationBuilder ab = newAnnotationBuilder(annType);
        if (meta == null)
            return ab;
        addAnnotation(ab, meta);
        return ab;
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

    @Override
    protected void serializeClassMappingContent(ClassMetaData mapping) {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        AnnotationBuilder abTable = addAnnotation(Table.class, mapping);
        serializeTable(info.getTableName(), Strings
            .getClassName(mapping.getDescribedType()), null,
            info.getUniques(), abTable);
        serializeColumns(info, ColType.PK_JOIN, null, abTable, cls);
        for (String second : info.getSecondaryTableNames()) {
            AnnotationBuilder abSecTable =
                addAnnotation(SecondaryTable.class, mapping);
            serializeTable(second, null, info, null, abSecTable);
        }
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

            .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

Examples of org.apache.openjpa.persistence.AnnotationBuilder

                    serializeColumn(col, ColType.PK_JOIN,
                        null, false, ab, null);
            }
            if (uniques != null) {
                for (Unique unique: uniques) {
                    AnnotationBuilder abUniqueConst =
                        newAnnotationBuilder(UniqueConstraint.class);
                    serializeUniqueConstraint(unique, abUniqueConst);
                    ab.add("uniqueConstraints", abUniqueConst);
                }
            }
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

                // else no break
            case MANY_MANY:
                if (field.getMappingInfo().hasSchemaComponents()
                    || field.getElementMapping().getValueInfo()
                    .hasSchemaComponents()) {
                    AnnotationBuilder abJoinTbl =
                        addAnnotation(JoinTable.class, fmd);
                    String table = field.getMappingInfo().getTableName();
                    if (table != null) {
                        int index = table.indexOf('.');
                        if (index < 0)
                            abJoinTbl.add("name", table);
                        else {
                            abJoinTbl.add("schema", table.substring(0, index));
                            abJoinTbl.add("name", table.substring(index + 1));
                        }
                    }
                    serializeColumns(field.getMappingInfo(),
                        ColType.JOIN, null, abJoinTbl, null);
                    serializeColumns(field.getElementMapping().getValueInfo(),
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

    private void serializeColumns(MappingInfo info, ColType type,
        String secondary, AnnotationBuilder ab, Object meta) {
        List<Column> cols = (List<Column>) info.getColumns();
        if (cols == null)
            return;
        AnnotationBuilder abContainer = ab;
        if (cols.size() > 1) {
            Class grpType = type.getColumnGroupAnnotationType();
            if (null != grpType) {
                AnnotationBuilder abGrp = newAnnotationBuilder(grpType);
                if (null == ab)
                    addAnnotation(abGrp, meta);
                else
                    ab.add(null, abGrp);
                abContainer = abGrp;
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

     */
    private void serializeColumn(Column col, ColType type, String secondary,
        boolean unique, AnnotationBuilder ab, Object meta) {
        FieldMetaData fmd = meta instanceof FieldMetaData ?
            (FieldMetaData) meta : null;
        AnnotationBuilder abCol = newAnnotationBuilder(
            type.getColumnAnnotationType());
        if (col.getName() != null && (null == fmd ||
            !col.getName().equalsIgnoreCase(fmd.getName())))
            abCol.add("name", col.getName());
        if (col.getTypeName() != null)
            abCol.add("columnDefinition", col.getTypeName());
        if (col.getTarget() != null
            && (type == ColType.JOIN || type == ColType.INVERSE
            || type == ColType.PK_JOIN))
            abCol.add("referencedColumnName", col.getTarget());
        if (type == ColType.COL || type == ColType.JOIN
            || type == ColType.PK_JOIN) {
            if (unique)
                abCol.add("unique", true);
            if (col.isNotNull())
                abCol.add("nullable", false);
            if (col.getFlag(Column.FLAG_UNINSERTABLE))
                abCol.add("insertable", false);
            if (col.getFlag(Column.FLAG_UNUPDATABLE))
                abCol.add("updatable", false);
            if (secondary != null)
                abCol.add("table", secondary);

            if (type == ColType.COL) {
                if (col.getSize() > 0 && col.getSize() != 255)
                    abCol.add("length", col.getSize());
                if (col.getDecimalDigits() != 0)
                    abCol.add("scale", col.getDecimalDigits());
            }
        }

        if (type != ColType.COL || abCol.hasComponents()) {
            if (null != ab) {
                String key = null;
                if (ab.getType() == JoinTable.class) {
                    switch(type) {
                        case JOIN:
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

    /**
     * Serialize given result set mapping.
     */
    private void serializeQueryResultMapping(QueryResultMapping meta,
        ClassMetaData clsmeta) {
        AnnotationBuilder ab = addAnnotation(SqlResultSetMapping.class, meta);
        if (null != clsmeta)
            addAnnotation(ab, clsmeta);
        ab.add("name", meta.getName());
        for (QueryResultMapping.PCResult pc : meta.getPCResults()) {
            AnnotationBuilder abEntRes =
                newAnnotationBuilder(EntityResult.class);
            ab.add("entities", abEntRes);
            abEntRes.add("entityClass", pc.getCandidateType());
            Object discrim = pc.getMapping(pc.DISCRIMINATOR);
            if (discrim != null)
                abEntRes.add("discriminatorColumn", discrim.toString());

            for (String path : pc.getMappingPaths()) {
                AnnotationBuilder abFldRes =
                    newAnnotationBuilder(FieldResult.class);
                abEntRes.add("fields", abFldRes);
                abFldRes.add("name", path);
                abFldRes.add("column", pc.getMapping(path).toString());
            }
        }
        for (Object col : meta.getColumnResults()) {
            AnnotationBuilder abColRes =
                newAnnotationBuilder(ColumnResult.class);
            abColRes.add("name", col.toString());
        }
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

        if (SequenceMapping.IMPL_VALUE_TABLE.equals(meta.getSequencePlugin())) {
            super.serializeSequence(meta);
            return;
        }

        AnnotationBuilder abTblGen = addAnnotation(TableGenerator.class, meta);
        SequenceMapping seq = (SequenceMapping) meta;
        abTblGen.add("name", seq.getName());
        String table = seq.getTable();
        if (table != null) {
            int dotIdx = table.indexOf('.');
            if (dotIdx == -1)
                abTblGen.add("table", table);
            else {
                abTblGen.add("table", table.substring(dotIdx + 1));
                abTblGen.add("schema", table.substring(0, dotIdx));
            }
        }
        if (!StringUtils.isEmpty(seq.getPrimaryKeyColumn()))
            abTblGen.add("pkColumnName", seq.getPrimaryKeyColumn());
        if (!StringUtils.isEmpty(seq.getSequenceColumn()))
            abTblGen.add("valueColumnName", seq.getSequenceColumn());
        if (!StringUtils.isEmpty(seq.getPrimaryKeyValue()))
            abTblGen.add("pkColumnValue", seq.getPrimaryKeyValue());
        if (seq.getAllocate() != 50 && seq.getAllocate() != -1)
            abTblGen.add("allocationSize", seq.getAllocate() + "");
        if (seq.getInitialValue() != 0 && seq.getInitialValue() != -1)
            abTblGen.add("initialValue", seq.getInitialValue() + "");
    }
View Full Code Here

Examples of org.apache.openjpa.persistence.AnnotationBuilder

     * Creates an an annotation builder for the specified class metadata
     * and adds it to list of builders.
     */
    protected AnnotationBuilder addAnnotation(
        Class<? extends Annotation> annType, QueryResultMapping meta) {
        AnnotationBuilder ab = newAnnotationBuilder(annType);
        if (meta == null)
            return ab;
        addAnnotation(ab, meta);
        return ab;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.