MentaBean

Compare Revisions

Ignore whitespace Rev 206 → Rev 207

/trunk/src/test/java/org/mentabean/jdbc/QueryBuilderTest.java
1415,6 → 1415,48
.executeQuery().size());
assertEquals(6, builder
.select(p, e, c)
.from(p)
.leftJoin(c).pkOf(c).in(p)
.inProperty(p.pxy().getCompany())
.leftJoin(e).pkOf(e).in(p)
.inProperty(p.pxy().getEmployee())
.where()
.clauseIf(true, c.pxy().getName())
.condition(new Like("Google"))
.and()
.openPar()
.clauseIf(false, c.pxy().getName())
.condition(new Like("Oracle"))
.closePar()
.or()
.clauseIf(true, c.pxy().getName())
.condition(new Like("Oracle"))
.executeQuery().size());
assertEquals(0, builder
.select(p, e, c)
.from(p)
.leftJoin(c).pkOf(c).in(p)
.inProperty(p.pxy().getCompany())
.leftJoin(e).pkOf(e).in(p)
.inProperty(p.pxy().getEmployee())
.where()
.clauseIf(true, c.pxy().getName())
.condition(new Like("Google"))
.and()
.openPar()
.openPar()
.clauseIf(false, c.pxy().getName())
.condition(new Like("Oracle"))
.closePar()
.or()
.clauseIf(true, c.pxy().getName())
.condition(new Like("Oracle"))
.closePar()
.executeQuery().size());
assertEquals(6, builder
.selectDistinct(p, e, c)
.from(p)
.leftJoin(c).pkOf(c).in(p)
/trunk/src/main/java/org/mentabean/jdbc/QueryBuilder.java
33,7 → 33,7
public class QueryBuilder {
 
private static final String REGEX = "(AND|OR|\\([\\s]*?\\)|WHERE|HAVING)[\\s]*?$";
private static final String NO_CLAUSE_REGEX = ".*(WHERE|HAVING)[\\s]*?$";
private static final String NO_CLAUSE_REGEX = ".*(WHERE|HAVING|\\()[\\s]*?$";
private StringBuilder sb = new StringBuilder();
private final AnsiSQLBeanSession session;
private List<Object> paramValues = new ArrayList<Object>();