Package org.apache.openjpa.jdbc.meta

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


        String val = attrs.getValue("strategy");
        if (val == null)
            return true;

        ClassMapping cm = (ClassMapping) currentElement();
        ClassMappingInfo info = cm.getMappingInfo();
        switch (Enum.valueOf(InheritanceType.class, val)) {
            case SINGLE_TABLE:
                info.setHierarchyStrategy(FlatClassStrategy.ALIAS);
                break;
            case JOINED:
                info.setHierarchyStrategy(VerticalClassStrategy.ALIAS);
                break;
            case TABLE_PER_CLASS:
                info.setHierarchyStrategy(FullClassStrategy.ALIAS);
                break;
        }
        return true;
    }
View Full Code Here


    private void endUniqueConstraint() {
        Unique unique = (Unique) popElement();
        Object ctx = currentElement();
        DBIdentifier tableName = DBIdentifier.newTable("?");
        if (ctx instanceof ClassMapping) {
          ClassMappingInfo info = ((ClassMapping) ctx).getMappingInfo();
          tableName = (_secondaryTable == null)
            ? info.getTableIdentifier() : DBIdentifier.newTable(_secondaryTable, delimit());
          info.addUnique(tableName, unique);
        } else if (ctx instanceof FieldMapping) {// JoinTable
          FieldMappingInfo info = ((FieldMapping)ctx).getMappingInfo();
          info.addJoinTableUnique(unique);
        } else if (ctx instanceof SequenceMapping) {
          SequenceMapping seq = (SequenceMapping)ctx;
          unique.setTableIdentifier(seq.getTableIdentifier());
          Column[] uniqueColumns = unique.getColumns();
          DBIdentifier[] columnNames = new DBIdentifier[uniqueColumns.length];
View Full Code Here

    }

    @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(info.getTableName()), abTable);
        serializeColumns(info, ColType.PK_JOIN, null, abTable, cls);
        for (String second : info.getSecondaryTableNames()) {
            AnnotationBuilder abSecTable =
                addAnnotation(SecondaryTable.class, mapping);
            serializeTable(second, null, info, info.getUniques(second), abSecTable);
        }
    }
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);
View Full Code Here

    public void map(boolean adapt) {
        ClassMapping sup = cls.getMappedPCSuperclassMapping();
        if (sup == null)
            throw new MetaDataException(_loc.get("not-sub", cls));

        ClassMappingInfo info = cls.getMappingInfo();
        info.assertNoIndex(cls, false);
        info.assertNoUnique(cls, false);

        // foreign key from this class to our superclass
        Table table = info.getTable(cls, adapt);
        ForeignKey fk = info.getSuperclassJoin(cls, table, adapt);
        Column[] pkCols = fk.getColumns();

        cls.setTable(table);
        cls.setJoinForeignKey(fk);
        cls.setPrimaryKeyColumns(pkCols);
        cls.setColumnIO(info.getColumnIO());

        // add a primary key if we don't have one already
        PrimaryKey pk = table.getPrimaryKey();
        if (pk == null) {
            String pkname = null;
View Full Code Here

    public void map(boolean adapt) {
        ValueMapping vm = cls.getEmbeddingMapping();
        if (vm == null || vm.getType() != cls.getDescribedType())
            throw new MetaDataException(_loc.get("not-embed", cls));

        ClassMappingInfo info = cls.getMappingInfo();
        info.assertNoSchemaComponents(cls, true);

        ClassMapping owner = vm.getFieldMapping().getDefiningMapping();
        cls.setIdentityType(owner.getIdentityType());
        cls.setObjectIdType(owner.getObjectIdType(),
            owner.isObjectIdTypeShared());
View Full Code Here

    public void map(boolean adapt) {
        ClassMapping sup = cls.getMappedPCSuperclassMapping();
        if (sup == null || cls.getEmbeddingMetaData() != null)
            throw new MetaDataException(_loc.get("not-sub", cls));

        ClassMappingInfo info = cls.getMappingInfo();
        info.assertNoSchemaComponents(cls, true);

        if (info.getTableName() != null) {
            Table table = info.createTable(cls, null, info.getSchemaName(),
                info.getTableName(), false);
            if (table != sup.getTable())
                throw new MetaDataException(_loc.get("flat-table", cls,
                    table.getFullName(), sup.getTable().getFullName()));
        }
View Full Code Here

    public void map(boolean adapt) {
        if (cls.getEmbeddingMetaData() != null)
            throw new MetaDataException(_loc.get("not-full", cls));

        ClassMapping sup = cls.getMappedPCSuperclassMapping();
        ClassMappingInfo info = cls.getMappingInfo();
        if (sup != null && info.isJoinedSubclass())
            throw new MetaDataException(_loc.get("not-full", cls));

        info.assertNoJoin(cls, true);
        info.assertNoForeignKey(cls, !adapt);
        info.assertNoIndex(cls, false);
        info.assertNoUnique(cls, false);

        // find class table
        Table table = info.getTable(cls, adapt);

        // find primary key column
        Column[] pkCols = null;
        if (cls.getIdentityType() == cls.ID_DATASTORE) {
            Column id = new Column();
            id.setName("id");
            id.setJavaType(JavaTypes.LONG);
            id.setComment("datastore id");
            if (cls.getIdentityStrategy() == ValueStrategies.AUTOASSIGN)
                id.setAutoAssigned(true);
            id.setNotNull(true);
            pkCols = info.getDataStoreIdColumns(cls, new Column[]{ id },
                table, adapt);
            cls.setPrimaryKeyColumns(pkCols);
            cls.setColumnIO(info.getColumnIO());
        }
        cls.setTable(table);

        // add a primary key if we don't have one already
        PrimaryKey pk = table.getPrimaryKey();
View Full Code Here

    @Override
    protected void serializeClassMappingContent(ClassMetaData mapping)
        throws SAXException {
        ClassMapping cls = (ClassMapping) mapping;
        ClassMappingInfo info = cls.getMappingInfo();
        serializeTable(info.getTableName(), "table", Strings
            .getClassName(mapping.getDescribedType()), null,
            info.getUniques(info.getTableName()));
        for (String second : info.getSecondaryTableNames())
            serializeTable(second, "secondary-table", null, info, info.getUniques(second));
        serializeColumns(info, ColType.PK_JOIN, 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))
View Full Code Here

TOP

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

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.