Java Code Examples for com.j256.ormlite.stmt.QueryBuilder#prepareStatementString()
The following examples show how to use
com.j256.ormlite.stmt.QueryBuilder#prepareStatementString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlServerDatabaseTypeTest.java From ormlite-jdbc with ISC License | 6 votes |
@Override @Test public void testLimitFormat() throws Exception { if (connectionSource == null) { return; } Dao<StringId, String> dao; try { connectionSource.setDatabaseType(databaseType); dao = createDao(StringId.class, false); } finally { connectionSource.setDatabaseType(new H2DatabaseType()); } QueryBuilder<StringId, String> qb = dao.queryBuilder(); long limit = 1232; qb.limit(limit); String query = qb.prepareStatementString(); assertTrue(query + " should start with stuff", query.startsWith("SELECT TOP " + limit + " ")); }
Example 2
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 5 votes |
/** * Prepare a statement string from a query builder * * @param qb * query builder * @return statement */ private String prepareStatementString( QueryBuilder<GeometryIndex, GeometryIndexKey> qb) { String sql = null; try { sql = qb.prepareStatementString(); } catch (SQLException e) { throw new GeoPackageException( "Failed to prepare statement from query builder", e); } return sql; }
Example 3
Source File: SqliteDatabaseTypeTest.java From ormlite-jdbc with ISC License | 5 votes |
@Test public void testLimitOffsetFormat() throws Exception { if (connectionSource == null) { return; } TableInfo<StringId, String> tableInfo = new TableInfo<StringId, String>(databaseType, StringId.class); QueryBuilder<StringId, String> qb = new QueryBuilder<StringId, String>(databaseType, tableInfo, null); long limit = 1232; qb.limit(limit); long offset = 171; qb.offset(offset); String query = qb.prepareStatementString(); assertTrue(query + " should contain LIMIT", query.contains(" LIMIT " + offset + "," + limit + " ")); }
Example 4
Source File: BaseJdbcDatabaseTypeTest.java From ormlite-jdbc with ISC License | 5 votes |
@Test public void testLimitFormat() throws Exception { if (connectionSource == null) { return; } if (!databaseType.isLimitSqlSupported()) { return; } TableInfo<StringId, String> tableInfo = new TableInfo<StringId, String>(databaseType, StringId.class); QueryBuilder<StringId, String> qb = new QueryBuilder<StringId, String>(databaseType, tableInfo, null); long limit = 1232; qb.limit(limit); String query = qb.prepareStatementString(); assertTrue(query + " should contain LIMIT", query.contains(" LIMIT " + limit + " ")); }
Example 5
Source File: HsqldbDatabaseTypeTest.java From ormlite-jdbc with ISC License | 5 votes |
@Override @Test public void testLimitFormat() throws Exception { connectionSource.setDatabaseType(databaseType); BaseDaoImpl<StringId, String> dao = new BaseDaoImpl<StringId, String>(connectionSource, StringId.class) { }; dao.initialize(); QueryBuilder<StringId, String> qb = dao.queryBuilder(); long limit = 1232; qb.limit(limit); String query = qb.prepareStatementString(); assertTrue(query + " should start with stuff", query.startsWith("SELECT LIMIT 0 " + limit + " ")); }