Examples of DbEntity


Examples of org.apache.cayenne.map.DbEntity

                    // defer DataRows -> Objects conversion till we are completely done.
                }

                // continue reading ids
                DbEntity entity = rootEntity.getDbEntity();
                while (it.hasNextRow()) {
                    elementsList.add(it.nextId(entity));
                }

                QueryLogger.logSelectCount(elementsList.size(), System
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        if (shouldDropTables) {
            ListIterator<DbEntity> it = dbEntitiesInInsertOrder
                    .listIterator(dbEntitiesInInsertOrder.size());
            while (it.hasPrevious()) {
                DbEntity ent = it.previous();
                list.addAll(dropTables.get(ent.getName()));
            }
        }

        if (shouldCreateTables) {
            for (final DbEntity ent : dbEntitiesInInsertOrder) {
                list.add(createTables.get(ent.getName()));
            }
        }

        if (shouldCreateFKConstraints) {
            for (final DbEntity ent : dbEntitiesInInsertOrder) {
                List<String> fks = createConstraints.get(ent.getName());
                list.addAll(fks);
            }
        }

        if (shouldDropPKSupport) {
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

            // drop tables
            if (shouldDropTables) {
                ListIterator<DbEntity> it = dbEntitiesInInsertOrder
                        .listIterator(dbEntitiesInInsertOrder.size());
                while (it.hasPrevious()) {
                    DbEntity ent = it.previous();
                    for (String statement : dropTables.get(ent.getName())) {
                        safeExecute(connection, statement);
                    }
                }
            }

            // create tables
            List<String> createdTables = new ArrayList<String>();
            if (shouldCreateTables) {
                for (final DbEntity ent : dbEntitiesInInsertOrder) {

                    // only create missing tables

                    safeExecute(connection, createTables.get(ent.getName()));
                    createdTables.add(ent.getName());
                }
            }

            // create FK
            if (shouldCreateTables && shouldCreateFKConstraints) {
                for (DbEntity ent : dbEntitiesInInsertOrder) {

                    if (createdTables.contains(ent.getName())) {
                        List<String> fks = createConstraints.get(ent.getName());
                        for (String fk : fks) {
                            safeExecute(connection, fk);
                        }
                    }
                }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

            DataContext context,
            ClassDescriptor descriptor,
            boolean refresh,
            boolean resolveInheritanceHierarchy) {
        // sanity check
        DbEntity dbEntity = descriptor.getEntity().getDbEntity();
        if (dbEntity == null) {
            throw new CayenneRuntimeException("ObjEntity '"
                    + descriptor.getEntity().getName()
                    + "' has no DbEntity.");
        }

        this.primaryKey = dbEntity.getPrimaryKeys();
        if (primaryKey.size() == 0) {
            throw new CayenneRuntimeException("Won't be able to create ObjectId for '"
                    + descriptor.getEntity().getName()
                    + "'. Reason: DbEntity '"
                    + dbEntity.getName()
                    + "' has no Primary Key defined.");
        }

        this.context = context;
        this.cache = context.getObjectStore().getDataRowCache();
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

                .getIncomingRelationships(resolveId(id.getEntityId()));

        // append tail of flattened relationships...
        if (id.getDbPath() != null) {

            DbEntity entity;

            if (incoming == null || incoming.isEmpty()) {
                entity = compiledExpression
                        .getEntityDescriptor(id.getEntityId())
                        .getEntity()
                        .getDbEntity();
            }
            else {
                DbRelationship last = incoming.get(incoming.size() - 1);
                entity = (DbEntity) last.getTargetEntity();
            }

            incoming = new ArrayList<DbRelationship>(incoming);

            Iterator<?> it = entity.resolvePathComponents(id.getDbPath());
            while (it.hasNext()) {
                incoming.add((DbRelationship) it.next());
            }
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        if (descriptor == null) {
            throw new EJBQLException("Invalid identification variable: "
                    + expression.getText());
        }

        DbEntity table = descriptor.getEntity().getDbEntity();
        String alias = context.getTableAlias(expression.getText(), table
                .getFullyQualifiedName());

        Collection<DbAttribute> pks = table.getPrimaryKeys();

        if (pks.size() == 1) {
            DbAttribute pk = pks.iterator().next();
            context.append(' ').append(alias).append('.').append(pk.getName());
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        // EJBQL queries are polymorphic by definition - there is no distinction between
        // inheritance/no-inheritance fetch
        descriptor.visitAllProperties(visitor);

        // append id columns ... (some may have been appended already via relationships)
        DbEntity table = descriptor.getEntity().getDbEntity();
        for (DbAttribute pk : table.getPrimaryKeys()) {
            appendColumn(idVar, null, pk, fields);
        }

        // append inheritance discriminator columns...
        Iterator<DbAttribute> discriminatorColumns = descriptor.getDiscriminatorColumns();
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

            ObjAttribute property,
            DbAttribute column,
            Map<String, String> fields,
            String javaType) {

        DbEntity table = (DbEntity) column.getEntity();
        String alias = context.getTableAlias(identifier, table.getFullyQualifiedName());
        String columnName = alias + "." + column.getName();

        Set<String> columns = getColumns();

        if (columns.add(columnName)) {
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

    public void testGeneratedJoinInFlattenedRelationship() throws Exception {

        // before saving objects, let's manually access PKGenerator to get a base PK value
        // for comparison
        DbEntity joinTableEntity = context.getEntityResolver().getDbEntity(
                joinTable.getTableName());
        DbAttribute pkAttribute = (DbAttribute) joinTableEntity.getAttribute("ID");
        Number pk = (Number) adapter.getPkGenerator().generatePk(node, pkAttribute);

        GeneratedF1 f1 = context.newObject(GeneratedF1.class);
        GeneratedF2 f2 = context.newObject(GeneratedF2.class);
        f1.addToF2(f2);
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        assertSame(getNode().getAdapter(), gen.getAdapter());
    }

    public void testPkFilteringLogic() throws Exception {
        DataMap map = getDomain().getDataMap("testmap");
        DbEntity artistExhibit = map.getDbEntity("ARTIST_EXHIBIT");
        DbEntity exhibit = map.getDbEntity("EXHIBIT");

        // sanity check
        assertNotNull(artistExhibit);
        assertNotNull(exhibit);
        assertNotNull(gen.dbEntitiesRequiringAutoPK);
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.