Browse files

more ops

  • Loading branch information...
1 parent 651f8ae commit 19594a939f16ad3d0cf43da8530d3f7016615c20 @kazuho committed Jul 9, 2014
Showing with 14 additions and 2 deletions.
  1. +2 −2 net/examp1e/picoorm/example/Main.java
  2. +12 −0 net/examp1e/picoorm/types/AbstractType.java
View
4 net/examp1e/picoorm/example/Main.java
@@ -29,8 +29,8 @@ public static void main(String[] args) {
// UPDATE member SET name=? WHERE name=?
Member.name.is("yappo").update(conn, new Member().setName("seiitaishogun"));
- // SELECT FROM member WHERE id<?
- for (Member m: Member.id.lessThan(1000L).limit(1).search(conn)) {
+ // SELECT FROM member WHERE id BETWEEN ? AND ?
+ for (Member m: Member.id.between(1L, 1000L).limit(1).search(conn)) {
System.out.println(Long.toString(m.getId()) + ":" + m.getName());
}
View
12 net/examp1e/picoorm/types/AbstractType.java
@@ -64,6 +64,18 @@ public ThisType init(TableDefinition<Row> tableDefinition, String fieldName) {
public Condition<Row> lessThan(ValueType x) {
return _buildBinaryOp("<", x);
}
+ public Condition<Row> greaterThan(ValueType x) {
+ return _buildBinaryOp(">", x);
+ }
+ public Condition<Row> lessThanOrEqualTo(ValueType x) {
+ return _buildBinaryOp("<=", x);
+ }
+ public Condition<Row> greaterThanOrEqualTo(ValueType x) {
+ return _buildBinaryOp(">=", x);
+ }
+ public Condition<Row> between(ValueType x, ValueType y) {
+ return new Condition<Row>(this.tableDefinition, this.fieldName + " BETWEEN ? AND ?", createParameter(x), createParameter(y));
+ }
private Condition<Row> _buildBinaryOp(String op, ValueType value) {
return new Condition<Row>(this.tableDefinition, this.fieldName + op + "?", createParameter(value));
}

0 comments on commit 19594a9

Please sign in to comment.