Package org.springmodules.datamap.dao

Examples of org.springmodules.datamap.dao.DataMapper


        jdbcTemplate.execute("drop table beers");
    }

    public void testSimpleFind() throws Exception {
        jdbcTemplate.execute("insert into beers (id, brand) values(12, 'Amstel')");
        DataMapper am = new ActiveMapper(Beer.class);
        am.setDataSource(jdbcTemplate.getDataSource());
        am.afterPropertiesSet();
        Beer b = (Beer) am.find(new Long(12));
        assertEquals("correct beer found", "Amstel", b.getBrand());
    }
View Full Code Here


        Beer b = (Beer) am.find(new Long(12));
        assertEquals("correct beer found", "Amstel", b.getBrand());
    }

    public void testSimpleAdd() throws Exception {
        DataMapper am = new ActiveMapper(Beer.class);
        am.setDataSource(jdbcTemplate.getDataSource());
        am.afterPropertiesSet();
        Beer b = new Beer();
        b.setBrand("Heineken");
        am.save(b);
        assertNotNull(b.getId());
        assertEquals("new beer is in db", 1, jdbcTemplate.queryForInt("select count(*) from beers where brand = 'Heineken'"));
    }
View Full Code Here

TOP

Related Classes of org.springmodules.datamap.dao.DataMapper

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.