Examples of Discriminator


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

        assertEquals(1, _mapping.getPrimaryKeyColumns().length);
        assertEquals("OID", _mapping.getPrimaryKeyColumns()[0].getName());
    }

    public void testDiscriminator() {
        Discriminator disc = _mapping.getDiscriminator();
        assertTrue(disc.getStrategy() instanceof
            ClassNameDiscriminatorStrategy);
        assertEquals(1, disc.getColumns().length);
        assertEquals("DISCRIM", disc.getColumns()[0].getName());
    }
View Full Code Here

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

    private void verifyTypeOperation(Value val, Value param, boolean isNotEqual) {
        if (val.getPath() == null)
            return;
        PCPath path = (PCPath) val.getPath();
        Discriminator disc = ((Type) val).getDiscriminator();
        if (disc == null || !(val.getMetaData().getPCSuperclass() != null ||
            val.getMetaData().getPCSubclasses().length > 0))
            throw new UserException(_loc.
                get("invalid-type-argument", path.last() != null ? path.getPCPathString() : path.getSchemaAlias()));
       
        if (disc.getColumns().length == 0) {
            if (disc.getStrategy() instanceof NoneDiscriminatorStrategy) {
                // limited support for table per class inheritance hierarchy
                if (path.last() != null)
                    throw new UserException(_loc.
                        get("type-argument-unsupported", path.last().getName()));
                if (isNotEqual) {
View Full Code Here

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

            pstate.field.appendIndex(sql, sel, pstate.joins);
    }

    public void appendType(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer sql) {
        Discriminator disc = null;
        ClassMapping sup = _class;
        while (sup.getMappedPCSuperclassMapping() != null)
            sup = sup.getMappedPCSuperclassMapping();

        disc = sup.getDiscriminator();

        Column[] cols = null;
        if (disc != null)
            cols = disc.getColumns();
        else
            cols = getColumns(state);

        if (cols == null || cols.length == 0) {
            sql.append("1");
View Full Code Here

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

        assertNotNull(vers);
        assertEquals("MAPPINGTEST1", vers.getColumns()[0].getTable().
            getName().toUpperCase());
        assertEquals(Types.INTEGER, vers.getColumns()[0].getType());

        Discriminator cls = _mapping.getDiscriminator();
        assertNotNull(cls);
        assertEquals("MAPPINGTEST1", cls.getColumns()[0].getTable().
            getName().toUpperCase());
        assertEquals(Types.VARCHAR, cls.getColumns()[0].getType());
    }
View Full Code Here

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

            verts = getVerticalMappings(mappings[i], subclasses, exps[i],
                subclassMode);
            if (verts.length == 1 && subclasses)
                subclassBits.set(sels.size());

            Discriminator disc = mappings[i].getDiscriminator();
            if (mappings.length > 1 && disc != null && disc.getColumns().length == 0 &&
                disc.getStrategy() instanceof NoneDiscriminatorStrategy)
                ctx.tpcMeta = mappings[i];

            // create criteria select and clone for each vert mapping
            sel = ((JDBCExpressionFactory) facts[i]).getSelectConstructor().
                evaluate(ctx, null, null, exps[i], states[i]);
View Full Code Here

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

            col.setIdentifier(DBIdentifier.newColumn(dcol.name(),delimit()));
        }
        if (!StringUtils.isEmpty(dcol.columnDefinition())) {
            col.setTypeIdentifier(DBIdentifier.newColumnDefinition(dcol.columnDefinition()));
        }
        Discriminator discrim = cm.getDiscriminator();
        switch (dcol.discriminatorType()) {
            case CHAR:
                col.setJavaType(JavaTypes.CHAR);
                discrim.setJavaType(JavaTypes.CHAR);
                break;
            case INTEGER:
                col.setJavaType(JavaTypes.INT);
                if (dcol.length() != 31)
                    col.setSize(dcol.length());
                discrim.setJavaType(JavaTypes.INT);
                break;
            default:
                col.setJavaType(JavaTypes.STRING);
                col.setSize(dcol.length());
                discrim.setJavaType(JavaTypes.STRING);
        }
        cm.getDiscriminator().getMappingInfo().setColumns
            (Arrays.asList(new Column[]{ col }));
    }
View Full Code Here

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

            pstate.field.appendIndex(sql, sel, pstate.joins);
    }

    public void appendType(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer sql) {
        Discriminator disc = null;
        ClassMapping sup = _class;
        while (sup.getMappedPCSuperclassMapping() != null)
            sup = sup.getMappedPCSuperclassMapping();

        disc = sup.getDiscriminator();

        Column[] cols = null;
        if (disc != null)
            cols = disc.getColumns();
        else
            cols = getColumns(state);

        if (cols == null || cols.length == 0) {
            sql.append("1");
View Full Code Here

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

    /**
     * Makes sure all subclasses of the given type are loaded in the JVM.
     * This is usually done automatically.
     */
    public void loadSubclasses(ClassMapping mapping) {
        Discriminator dsc = mapping.getDiscriminator();
        if (dsc.getSubclassesLoaded())
            return;

        // if the subclass list is set, no need to load subs
        if (mapping.getRepository().getPersistentTypeNames(false,
            _ctx.getClassLoader()) != null) {
            dsc.setSubclassesLoaded(true);
            return;
        }

        try {
            dsc.loadSubclasses(this);
        } catch (ClassNotFoundException cnfe) {
            throw new StoreException(cnfe);
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, _dict);
        }
View Full Code Here

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

            pstate.field.appendIndex(sql, sel, pstate.joins);
    }

    public void appendType(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer sql) {
        Discriminator disc = null;
        ClassMapping sup = _class;
        while (sup.getMappedPCSuperclassMapping() != null)
            sup = sup.getMappedPCSuperclassMapping();

        disc = sup.getDiscriminator();

        Column[] cols = null;
        if (disc != null)
            cols = disc.getColumns();
        else
            cols = getColumns(state);

        if (cols == null) {
            sql.append("1");
View Full Code Here

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

    /**
     * Makes sure all subclasses of the given type are loaded in the JVM.
     * This is usually done automatically.
     */
    public void loadSubclasses(ClassMapping mapping) {
        Discriminator dsc = mapping.getDiscriminator();
        if (dsc.getSubclassesLoaded())
            return;

        // if the subclass list is set, no need to load subs
        if (mapping.getRepository().getPersistentTypeNames(false,
            _ctx.getClassLoader()) != null) {
            dsc.setSubclassesLoaded(true);
            return;
        }

        try {
            dsc.loadSubclasses(this);
        } catch (ClassNotFoundException cnfe) {
            throw new StoreException(cnfe);
        } catch (SQLException se) {
            throw SQLExceptions.getStore(se, _dict);
        }
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.