[#890] Add Factory.selectCount() convenience method

This commit is contained in:
Lukas Eder 2011-10-30 07:30:29 +00:00
parent 84e1eab570
commit a8aa1fe48e
2 changed files with 26 additions and 0 deletions

View File

@ -2176,6 +2176,12 @@ public abstract class jOOQAbstractTest<
assertEquals("test", result.get(0).getValue(f3));
}
@Test
public void testSelectCountQuery() throws Exception {
assertEquals(4, create().selectCount().from(TBook()).fetchOne(0));
assertEquals(2, create().selectCount().from(TAuthor()).fetchOne(0));
}
@Test
public void testSelectQuery() throws Exception {
SelectQuery q = create().selectQuery();

View File

@ -1028,6 +1028,26 @@ public class Factory implements Configuration {
return new SelectImpl(this).select(one());
}
/**
* Create a new DSL select statement for <code>COUNT(*)</code>
* <p>
* Example: <code><pre>
* Factory create = new Factory();
*
* create.selectCount()
* .from(table1)
* .join(table2).on(field1.equal(field2))
* .where(field1.greaterThan(100))
* .orderBy(field2)
* .execute();
* </pre></code>
*
* @see #one()
*/
public final SelectSelectStep selectCount() {
return new SelectImpl(this).select(count());
}
/**
* Create a new DSL select statement.
* <p>