Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.DataMap


    private void tableExistfForThrowOnPartialAndMixStrategy(String strategy)
            throws Exception {

        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();
        DataNode dataNode = createDataNode(map);
        int sizeDB = getNameTablesInDB(dataNode).size();
        generateDBWithDBGeneratorStrategy(dataNode, query, observer);
View Full Code Here


        }

    }

    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

import org.apache.cayenne.unit.CayenneCase;

public class OracleAdapterTest extends CayenneCase {

    public void testUpdatesLOBColumns() throws Exception {
        DataMap map = getDomain().getDataMap("testmap");
        assertTrue(OracleAdapter.updatesLOBColumns(new InsertBatchQuery(map
                .getDbEntity("BLOB_TEST"), 1)));
        assertTrue(OracleAdapter.updatesLOBColumns(new InsertBatchQuery(map
                .getDbEntity("CLOB_TEST"), 1)));
        assertFalse(OracleAdapter.updatesLOBColumns(new InsertBatchQuery(map
                .getDbEntity("ARTIST"), 1)));
    }
View Full Code Here

        Collection<DataMap> maps = descriptor.getDataMaps();
        assertEquals(2, maps.size());

        Iterator<DataMap> mapsIt = maps.iterator();

        DataMap map1 = mapsIt.next();
        DataMap map2 = mapsIt.next();

        assertEquals("testConfigMap3_1", map1.getName());
        assertEquals("testConfigMap3_2", map2.getName());

        Collection<DataNodeDescriptor> nodes = descriptor.getNodeDescriptors();
        assertEquals(1, nodes.size());

        DataNodeDescriptor node1 = nodes.iterator().next();
View Full Code Here

    }

    public void testLoadWithMeaningfulPK() throws Exception {
        try {

            DataMap map = new DataMap();
            String tableLabel = getNode().getAdapter().tableTypeForTable();

            loader.setCreatingMeaningfulPK(true);
           
            List<DbEntity> testLoader = loader.getTables(
                    null,
                    null,
                    "artist",
                    new String[] {
                        tableLabel
                    });
            if(testLoader.size()==0){
                testLoader = loader.getTables(
                        null,
                        null,
                        "ARTIST",
                        new String[] {
                            tableLabel
                        });
            }
           
            loader.loadDbEntities(map, testLoader);

            loader.loadObjEntities(map);
            ObjEntity artist = map.getObjEntity("Artist");
            assertNotNull(artist);
            ObjAttribute id = (ObjAttribute) artist.getAttribute("artistId");
            assertNotNull(id);
        }
        finally {
View Full Code Here

        try {
            boolean supportsUnique = getNode().getAdapter().supportsUniqueConstraints();
            boolean supportsLobs = getAccessStackAdapter().supportsLobs();
            boolean supportsFK = getAccessStackAdapter().supportsFKConstraints();

            DataMap map = new DataMap();
            String tableLabel = getNode().getAdapter().tableTypeForTable();

            // *** TESTING THIS ***
            loader.loadDbEntities(map, loader.getTables(null, null, "%", new String[] {
                tableLabel
            }));

            assertDbEntities(map);

            if (supportsLobs) {
                assertLobDbEntities(map);
            }

            // *** TESTING THIS ***
            loader.loadDbRelationships(map);

            if (supportsFK) {
                Collection rels = getDbEntity(map, "ARTIST").getRelationships();
                assertNotNull(rels);
                assertTrue(rels.size() > 0);

                // test one-to-one
                rels = getDbEntity(map, "PAINTING").getRelationships();
                assertNotNull(rels);

                // find relationship to PAINTING_INFO
                DbRelationship oneToOne = null;
                Iterator it = rels.iterator();
                while (it.hasNext()) {
                    DbRelationship rel = (DbRelationship) it.next();
                    if ("PAINTING_INFO".equalsIgnoreCase(rel.getTargetEntityName())) {
                        oneToOne = rel;
                        break;
                    }
                }

                assertNotNull("No relationship to PAINTING_INFO", oneToOne);
                assertFalse("Relationship to PAINTING_INFO must be to-one", oneToOne
                        .isToMany());
                assertTrue("Relationship to PAINTING_INFO must be to-one", oneToOne
                        .isToDependentPK());

                // test UNIQUE only if FK is supported...
                if (supportsUnique) {
                    assertUniqueConstraintsInRelationships(map);
                }
            }

            // *** TESTING THIS ***
            loader.setCreatingMeaningfulPK(false);
            loader.loadObjEntities(map);

            ObjEntity ae = map.getObjEntity("Artist");
            assertNotNull(ae);
            assertEquals("Artist", ae.getName());
            // assert primary key is not an attribute
            assertNull(ae.getAttribute("artistId"));
            if (supportsLobs) {
View Full Code Here

        CayenneContext context = new CayenneContext(channel);
        ObjEntity entity = new ObjEntity("test_entity");
        entity.setClassName(MockPersistentObject.class.getName());

        DataMap dataMap = new DataMap("test");
        dataMap.addObjEntity(entity);
        Collection<DataMap> entities = Collections.singleton(dataMap);
        context.setEntityResolver(new EntityResolver(entities));
        Persistent object = context.newObject(MockPersistentObject.class);

        // record change here to make it available to the anonymous connector method..
View Full Code Here

        CayenneContext context = new CayenneContext(new MockDataChannel());

        ObjEntity entity = new ObjEntity("test_entity");
        entity.setClassName(MockPersistentObject.class.getName());

        DataMap dataMap = new DataMap("test");
        dataMap.addObjEntity(entity);
        Collection<DataMap> entities = Collections.singleton(dataMap);
        context.setEntityResolver(new EntityResolver(entities));

        Persistent object = context.newObject(MockPersistentObject.class);
        assertNotNull(object);
View Full Code Here

        CayenneContext context = new CayenneContext(new MockDataChannel());
        ObjEntity entity = new ObjEntity("test_entity");
        entity.setClassName(MockPersistentObject.class.getName());

        DataMap dataMap = new DataMap("test");
        dataMap.addObjEntity(entity);
        Collection<DataMap> entities = Collections.singleton(dataMap);
        context.setEntityResolver(new EntityResolver(entities));

        // TRANSIENT ... should quietly ignore it
        Persistent transientObject = new MockPersistentObject();
View Full Code Here

        ServletUtil.initializeSharedConfiguration(servletContext);

        try {
            DataDomain cayenneDomain =
                Configuration.getSharedConfiguration().getDomain();
            DataMap dataMap = cayenneDomain.getMap("cayenneMap");
            DataNode dataNode = cayenneDomain.getNode("cayenneNode");

            initDatabaseSchema(dataNode, dataMap);

            loadDatabase();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.DataMap

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.