Package com.mysema.query.sql

Examples of com.mysema.query.sql.H2Templates


   
    private QSurvey survey = new QSurvey("survey");
   
    @Before
    public void setUp() {
        query = new SQLQuery(null, new H2Templates() {{
            newLineToSingleSpace();
        }});
    }
View Full Code Here


        stmt.execute("create table GENERATED_KEYS(" +
                 "ID int AUTO_INCREMENT PRIMARY KEY, " +
                 "NAME varchar(30))");

        QGeneratedKeysEntity entity = new QGeneratedKeysEntity("entity");
        SQLInsertClause insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        ResultSet rs = insertClause.set(entity.name, "Hello").executeWithKeys();
        ResultSetMetaData md = rs.getMetaData();
        System.out.println(md.getColumnName(1));
       
        assertTrue(rs.next());
        assertEquals(1, rs.getInt(1));
        assertFalse(rs.next());

        insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        rs = insertClause.set(entity.name, "World").executeWithKeys();
        assertTrue(rs.next());
        assertEquals(2, rs.getInt(1));
        assertFalse(rs.next());

        insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        assertEquals(3, insertClause.set(entity.name, "World").executeWithKey(entity.id).intValue());
       
        insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        assertEquals(Collections.singletonList(4), insertClause.set(entity.name, "World").executeWithKeys(entity.id));
    }
View Full Code Here

   
    private QSurvey survey = new QSurvey("survey");
   
    @Before
    public void setUp() {
        query = new SQLQuery(null, new H2Templates() {{
            newLineToSingleSpace();
        }});
    }
View Full Code Here

        stmt.execute("create table GENERATED_KEYS(" +
                 "ID int AUTO_INCREMENT PRIMARY KEY, " +
                 "NAME varchar(30))");

        QGeneratedKeysEntity entity = new QGeneratedKeysEntity("entity");
        SQLInsertClause insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        ResultSet rs = insertClause.set(entity.name, "Hello").executeWithKeys();
        ResultSetMetaData md = rs.getMetaData();
        System.out.println(md.getColumnName(1));
       
        assertTrue(rs.next());
        assertEquals(1, rs.getInt(1));
        assertFalse(rs.next());

        insertClause = new SQLInsertClause(conn, new H2Templates(), entity);
        rs = insertClause.set(entity.name, "World").executeWithKeys();
        assertTrue(rs.next());
        assertEquals(2, rs.getInt(1));
        assertFalse(rs.next());
View Full Code Here

    public static SQLTemplates getSQLTemplates() {
        switch (target.get()) {
        case CUBRID:return new CUBRIDTemplates();
        case DERBY: return new DerbyTemplates();
        case H2:    return new H2Templates();
        case HSQLDB:return new HSQLDBTemplates();
        case SQLSERVER: return new SQLServerTemplates();
        case MYSQL: return new MySQLTemplates();
        case ORACLE:return new OracleTemplates();
        case POSTGRES: return new PostgresTemplates();
View Full Code Here

TOP

Related Classes of com.mysema.query.sql.H2Templates

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.