Examples of DbEntity


Examples of org.apache.cayenne.map.DbEntity

        dataNode.performQueries(Collections.singletonList((Query) query), observer);
        assertTrue(dataNode.getSchemaUpdateStrategy() instanceof TestSchemaUpdateStrategy);
    }

    private void withOneTableForThrowOnPartialAndMixStrategy(String strategy) {
        DbEntity entity = null;
        String template = "SELECT #result('ARTIST_ID' 'int') FROM ARTIST ORDER BY ARTIST_ID";
        SQLTemplate query = new SQLTemplate(Object.class, template);
        DataMap map = getDataMap();
        assertNotNull(map);
        MockOperationObserver observer = new MockOperationObserver();
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

    }

    private DbEntity createOneTable(DataNode dataNode) {
        DataMap map = getDataMap();
        Collection<DbEntity> ent = map.getDbEntities();
        DbEntity entity = ent.iterator().next();
        String template = dataNode.getAdapter().createTable(entity);

        SQLTemplate query = new SQLTemplate(Object.class, template);
        MockOperationObserver observer = new MockOperationObserver();
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        public CountQuery(Class objectClass) {
            this.objectClass = objectClass;
        }

        protected Query createReplacementQuery(EntityResolver resolver) {
            DbEntity entity = resolver.lookupDbEntity(objectClass);

            if (entity == null) {
                throw new CayenneRuntimeException(
                    "No entity is mapped for java class: "
                    + objectClass.getName());
            }

            String sql = "SELECT #result('count(*)' 'int' 'C') FROM "
                + entity.getName();
            SQLTemplate replacement = new SQLTemplate(entity, sql);
            replacement.setFetchingDataRows(true);
            return replacement;
        }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        return (DeleteBatchQueryBuilder) new SoftDeleteQueryBuilderFactory().
            createDeleteQueryBuilder(adapter);
    }

    public void testCreateSqlString() throws Exception {
        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
                SoftTest.class).getDbEntity();

        List idAttributes = Collections.singletonList(entity
                .getAttribute("SOFT_TEST_ID"));

        DeleteBatchQuery deleteQuery = new DeleteBatchQuery(entity, idAttributes, null, 1);
        DeleteBatchQueryBuilder builder = createBuilder();
        String generatedSql = builder.createSqlString(deleteQuery);
        assertNotNull(generatedSql);
        assertEquals(
                "UPDATE " + entity.getName() + " SET DELETED = ? WHERE SOFT_TEST_ID = ?",
                generatedSql);
    }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

                "UPDATE " + entity.getName() + " SET DELETED = ? WHERE SOFT_TEST_ID = ?",
                generatedSql);
    }

    public void testCreateSqlStringWithNulls() throws Exception {
        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
                SoftTest.class).getDbEntity();

        List idAttributes = Arrays.asList(entity.getAttribute("SOFT_TEST_ID"), entity
                .getAttribute("NAME"));

        Collection nullAttributes = Collections.singleton("NAME");

        DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
                entity,
                idAttributes,
                nullAttributes,
                1);
        DeleteBatchQueryBuilder builder = createBuilder();
        String generatedSql = builder.createSqlString(deleteQuery);
        assertNotNull(generatedSql);
        assertEquals("UPDATE "
                + entity.getName()
                + " SET DELETED = ? WHERE SOFT_TEST_ID = ? AND NAME IS NULL", generatedSql);
    }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

                + entity.getName()
                + " SET DELETED = ? WHERE SOFT_TEST_ID = ? AND NAME IS NULL", generatedSql);
    }

    public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
                SoftTest.class).getDbEntity();
        try {

            entity.getDataMap().setQuotingSQLIdentifiers(true);
            List idAttributes = Collections.singletonList(entity
                    .getAttribute("SOFT_TEST_ID"));

            DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
                    entity,
                    idAttributes,
                    null,
                    1);
            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
            DeleteBatchQueryBuilder builder = createBuilder(adapter);
            String generatedSql = builder.createSqlString(deleteQuery);
           
            String charStart = adapter.getIdentifiersStartQuote();
            String charEnd = adapter.getIdentifiersEndQuote();

            assertNotNull(generatedSql);
            assertEquals("UPDATE "
                    + charStart
                    + entity.getName()
                    + charEnd
                    + " SET "
                    + charStart
                    + "DELETED"
                    + charEnd
                    + " = ? WHERE "
                    + charStart
                    + "SOFT_TEST_ID"
                    + charEnd
                    + " = ?", generatedSql);
        }
        finally {
            entity.getDataMap().setQuotingSQLIdentifiers(false);
        }

    }
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

    }
   
    public void testUpdate() throws Exception {
        final DataContext context = createDataContext();
        final DbEntity entity = context.getEntityResolver().lookupObjEntity(
                SoftTest.class).getDbEntity();
       
        try {
            context.getParentDataDomain().setQueryBuilderFactory(new SoftDeleteQueryBuilderFactory());
           
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        EntityResolver resolver = getDomain().getEntityResolver();

        // test with adapter that supports keys...
        DbAdapter adapter = buildAdapter(true);

        DbEntity dbEntity = resolver
                .lookupObjEntity(SimpleLockingTestEntity.class)
                .getDbEntity();

        List qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"), dbEntity.getAttribute("NAME"));

        Collection nullAttributeNames = Collections.singleton("NAME");

        Map qualifierSnapshot = new HashMap();
        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

        EntityResolver resolver = getDomain().getEntityResolver();

        // test with adapter that supports keys...
        DbAdapter adapter = buildAdapter(true);

        DbEntity dbEntity = resolver
                .lookupObjEntity(SimpleLockingTestEntity.class)
                .getDbEntity();

        List qualifierAttributes = Arrays.asList(dbEntity.getAttribute("LOCKING_TEST_ID"), dbEntity.getAttribute("NAME"));

        Collection nullAttributeNames = Collections.singleton("NAME");

        Map qualifierSnapshot = new HashMap();
        qualifierSnapshot.put("LOCKING_TEST_ID", new Integer(1));
View Full Code Here

Examples of org.apache.cayenne.map.DbEntity

            if (constraints == null || constraints.isEmpty()) {
                continue;
            }

            Object tableName = entry.getKey();
            DbEntity entity = map.getDbEntity(tableName.toString());
            if (entity == null) {
                continue;
            }
            boolean status = entity.getDataMap() != null
                    && entity.getDataMap().isQuotingSQLIdentifiers();
            QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);

            for (String constraint : constraints) {
                StringBuilder drop = new StringBuilder();
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.