Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.DbEntity.addAttribute()


        dbEntity2.addAttribute(e2col1);
        DbAttribute e2col2 = new DbAttribute("FK", Types.INTEGER, dbEntity2);
        dbEntity2.addAttribute(e2col2);
        DbAttribute e2col3 = new DbAttribute("NAME", Types.VARCHAR, dbEntity2);
        e2col3.setMaxLength(10);
        dbEntity2.addAttribute(e2col3);

        map.addDbEntity(dbEntity2);

        assertTokensAndExecute(node, map, 2, 0);
        assertTokensAndExecute(node, map, 0, 0);
View Full Code Here


        
        DbEntity entity = new DbEntity();
        DbAttribute attr = new DbAttribute();
        attr.setName("name column");
        attr.setType(1);
        entity.addAttribute(attr);
       
        DbKeyGenerator id = new DbKeyGenerator();
        entity.setPrimaryKeyGenerator(id);
       
        DataMap dm = new DataMap();       
View Full Code Here

        HSQLDBAdapter adapter = new HSQLDBAdapter();
        DbEntity e = new DbEntity("Test");
        DbAttribute dblPrec = new DbAttribute("dbl1");
        dblPrec.setType(Types.DOUBLE);
        dblPrec.setMaxLength(22);
        e.addAttribute(dblPrec);
       
        String sql = adapter.createTable(e);

        // CAY-1095.
        // Make sure the double type is preserved, but not precision constraints, due to a bug in HSQLDB.
View Full Code Here

    public void testCreateTableAddsCachedKeyword() {
        HSQLDBAdapter adapter = new HSQLDBAdapter();
        DbEntity e = new DbEntity("Test");
        DbAttribute dblPrec = new DbAttribute("dbl1");
        dblPrec.setType(Types.INTEGER);
        e.addAttribute(dblPrec);
       
        String sql = adapter.createTable(e);
       
        assertEquals(0,sql.indexOf("CREATE CACHED TABLE"));
    }
View Full Code Here

        try {

            column.setMandatory(true);
            column.setMaxLength(10);
            dbEntity.addAttribute(column);
            assertTokensAndExecute(node, map, 2, 0);

            // check that is was merged
            assertTokensAndExecute(node, map, 0, 0);
View Full Code Here

        DbEntity dbEntity = new DbEntity("NEW_TABLE");

        DbAttribute column1 = new DbAttribute("ID", Types.INTEGER, dbEntity);
        column1.setMandatory(true);
        column1.setPrimaryKey(true);
        dbEntity.addAttribute(column1);

        DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity);
        column2.setMaxLength(10);
        column2.setMandatory(false);
        dbEntity.addAttribute(column2);
View Full Code Here

        dbEntity.addAttribute(column1);

        DbAttribute column2 = new DbAttribute("NAME", Types.VARCHAR, dbEntity);
        column2.setMaxLength(10);
        column2.setMandatory(false);
        dbEntity.addAttribute(column2);

        map.addDbEntity(dbEntity);

        assertTokensAndExecute(node, map, 1, 0);
        assertTokensAndExecute(node, map, 0, 0);
View Full Code Here

        DbEntity dbEntity1 = new DbEntity("NEW_TABLE");

        DbAttribute e1col1 = new DbAttribute("ID1", Types.INTEGER, dbEntity1);
        e1col1.setMandatory(true);
        e1col1.setPrimaryKey(true);
        dbEntity1.addAttribute(e1col1);
        map.addDbEntity(dbEntity1);

        assertTokensAndExecute(node, map, 1, 0);
        assertTokensAndExecute(node, map, 0, 0);
       
View Full Code Here

        assertTokensAndExecute(node, map, 1, 0);
        assertTokensAndExecute(node, map, 0, 0);
       
        DbAttribute e1col2 = new DbAttribute("ID2", Types.INTEGER, dbEntity1);
        e1col2.setMandatory(true);
        dbEntity1.addAttribute(e1col2);
       
        assertTokensAndExecute(node, map, 2, 0);
        assertTokensAndExecute(node, map, 0, 0);

        e1col1.setPrimaryKey(false);
View Full Code Here

        // create and add new column to model and db
        DbAttribute column = new DbAttribute("NEWCOL2", Types.VARCHAR, dbEntity);

        column.setMandatory(false);
        column.setMaxLength(10);
        dbEntity.addAttribute(column);
        assertTokensAndExecute(node, map, 1, 0);

        // check that is was merged
        assertTokensAndExecute(node, map, 0, 0);
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.