Package org.apache.openjpa.jdbc.meta

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


    /**
     * Set the secondary table information back to the owning class mapping.
     */
    private void endSecondaryTable() {
        ClassMapping cm = (ClassMapping) currentElement();
        ClassMappingInfo info = cm.getMappingInfo();
        info.setSecondaryTableJoinColumns(DBIdentifier.newTable(_secondaryTable, delimit()), _joinCols);
        clearSecondaryTableInfo();
    }
View Full Code Here


        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

        ValueMapping vm = cls.getEmbeddingMapping();
        if (vm == null || vm.getType() != cls.getDescribedType()
            || vm.getTypeCode() != JavaTypes.OID)
            throw new MetaDataException(_loc.get("not-oid", cls));

        ClassMappingInfo info = cls.getMappingInfo();
        info.assertNoSchemaComponents(cls, true);
        cls.setTable(vm.getFieldMapping().getTable());
    }
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();
            DBDictionary dict = cls.getMappingRepository().getDBDictionary();
            DBIdentifier idName = DBIdentifier.newColumn("id", dict != null ? dict.delimitAll() : false);
            id.setIdentifier(idName);
            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

    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 (!DBIdentifier.isNull(info.getTableIdentifier())) {
            Table table = info.createTable(cls, null, info.getSchemaIdentifier(),
                info.getTableIdentifier(), 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) {
        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) {
            DBIdentifier pkname = DBIdentifier.NULL;
View Full Code Here

    /**
     * Set the secondary table information back to the owning class mapping.
     */
    private void endSecondaryTable() {
        ClassMapping cm = (ClassMapping) currentElement();
        ClassMappingInfo info = cm.getMappingInfo();
        info.setSecondaryTableJoinColumns(_secondaryTable, _joinCols);
        clearSecondaryTableInfo();
    }
View Full Code Here

        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();
        String tableName = "?";
        if (ctx instanceof ClassMapping) {
          ClassMappingInfo info = ((ClassMapping) ctx).getMappingInfo();
          tableName = (_secondaryTable == null)
            ? info.getTableName() : _secondaryTable;
          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.setTableName(seq.getTable());
          Column[] uniqueColumns = unique.getColumns();
          String[] columnNames = new String[uniqueColumns.length];
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.