Search in sources :

Example 6 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class FreeSelectSqlBuilderTest method testSetTemplate.

@Test
public void testSetTemplate() throws SQLException {
    FreeSelectSqlBuilder test = createTest();
    test.setTemplate(template).setTemplate(template);
    assertEquals(template + " " + template, test.build());
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Test(org.junit.Test)

Example 7 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class FreeSelectSqlBuilderTest method testBuildMeltdownAtBegining.

@Test
public void testBuildMeltdownAtBegining() throws SQLException {
    FreeSelectSqlBuilder test = createTest();
    test = createTest();
    test.where(template).ignoreNull(null).and().appendExpression(template).or().appendExpression(template).ignoreNull(null).groupBy(template);
    assertEquals("WHERE template GROUP BY [template]", test.build());
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Test(org.junit.Test)

Example 8 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class FreeSelectSqlBuilderTest method testCreate.

@Test
public void testCreate() throws SQLException {
    try {
        FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
        test = new FreeSelectSqlBuilder(DatabaseCategory.SqlServer);
    } catch (Exception e) {
        fail();
    }
    try {
        FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
        test.setLogicDbName(logicDbName);
        test.setDbCategory(DatabaseCategory.MySql);
        fail();
    } catch (Exception e) {
    }
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 9 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class FreeSelectSqlBuilderTest method testBuildSelect.

@Test
public void testBuildSelect() throws SQLException {
    FreeSelectSqlBuilder test = createTest();
    test.select(template, template, template).from(tableName).where(text(template)).groupBy(template);
    test.top(10).setHints(new DalHints().inTableShard(1));
    assertEquals("SELECT [template], [template], [template] FROM [dal_client_test_1] WITH (NOLOCK) WHERE template GROUP BY [template] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY", test.build());
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) Test(org.junit.Test)

Example 10 with FreeSelectSqlBuilder

use of com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder in project dal by ctripcorp.

the class FreeSelectSqlBuilderTest method testBuildMySqlTop.

@Test
public void testBuildMySqlTop() throws SQLException {
    FreeSelectSqlBuilder test = new FreeSelectSqlBuilder(DatabaseCategory.MySql);
    test.setTemplate(template).setTemplate(template).append(template);
    assertEquals("template template template", test.build());
    test.top(10);
    assertEquals("template template template limit 0, 10", test.build());
}
Also used : FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) Test(org.junit.Test)

Aggregations

FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)61 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)44 DalHints (com.ctrip.platform.dal.dao.DalHints)38 List (java.util.List)38 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 DalQueryDao (com.ctrip.platform.dal.dao.DalQueryDao)6 ShortRowMapper (com.ctrip.platform.dal.dao.helper.ShortRowMapper)6 DalDefaultJpaMapper (com.ctrip.platform.dal.dao.helper.DalDefaultJpaMapper)4 DatabaseSet (com.ctrip.platform.dal.daogen.entity.DatabaseSet)3 GenTaskByFreeSql (com.ctrip.platform.dal.daogen.entity.GenTaskByFreeSql)3 GenTaskBySqlBuilder (com.ctrip.platform.dal.daogen.entity.GenTaskBySqlBuilder)3 DalCustomRowMapper (com.ctrip.platform.dal.dao.helper.DalCustomRowMapper)2 FreeUpdateSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeUpdateSqlBuilder)2 DatabaseSetEntry (com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry)2 GenTaskByTableViewSp (com.ctrip.platform.dal.daogen.entity.GenTaskByTableViewSp)2 Project (com.ctrip.platform.dal.daogen.entity.Project)2 Map (java.util.Map)2 ClientTestModel (com.ctrip.platform.dal.dao.unitbase.ClientTestModel)1