Package org.fto.jthink.jdbc

Examples of org.fto.jthink.jdbc.Condition


    columns.put("F2", "2");
    columns.put("F3", "3");
    columns.put("F4", "4");
    columns.put("F5", "5");
   
    Condition condn = new Condition();
    Condition condn1 = new Condition();
    condn1.add(new ConditionItem("DeptId", "!=", "3"));
   
    Condition condn2 = new Condition();
    condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
    condn1.add("OR", condn2);
    condn.add(Condition.AND_NOT, new ConditionItem("DeptName", "like", "%部%"));
    condn.add(Condition.AND, condn1);
    condn.add(Condition.AND_NOT, new ConditionItem("DeptDesc", "like", "%技术%"));
View Full Code Here


   *方法测试
   */
  public void testconstructSQLForDelete() {
    System.out.println("\n[正在测试方法: SQLBuilder.constructSQLForDelete()...]");
   
    Condition condn = new Condition();
   
    Condition condn1 = new Condition();
    condn1.add(new ConditionItem("DeptId", "!=", "3"));
    Condition condn2 = new Condition();
    condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
    condn1.add("OR", condn2);
    condn.add(Condition.AND_NOT, new ConditionItem("DeptName", "like", "%部%"));
    condn.add(Condition.AND, condn1);

    /* constructSQLForDelete测试开始 */
 
View Full Code Here

   *方法测试
   */
  public void testconstructSQL_ForSelect$Condition() {
    System.out.println("\n[正在测试方法: SQLBuilder.testconstructSQL_ForSelect$Condition()...]");
   
    Condition condn = new Condition();
    condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
    condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
    condn.add(new ConditionItem("F1", "=", "1"));
    condn.add(new ConditionItem("F2", "=", "2"));
    condn.add(new ConditionItem("F3", "=", "3"));
    condn.add(new ConditionItem("F4", "=", "4"));
    condn.add(new ConditionItem("F5", "=", "5"));
    condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
   
   
    Column[] columns = new Column[]{
        new Column("DEPT_ID"),
        new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
View Full Code Here

   *方法测试
   */
  public void testconstructSQL_ForSelect() {
    System.out.println("\n[正在测试方法: SQLBuilder.constructSQL_ForSelect()...]");
   
    Condition condn = new Condition();
   
    Condition condn1 = new Condition();
    condn1.add(new ConditionItem("DeptId", "!=", "3"));
   
    Condition condn2 = new Condition();
    condn2.add(Condition.OR, new ConditionItem("DeptId", "!=", new Integer(2)));
    condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
   
    condn1.add("OR", condn2);
   
    condn.add(Condition.AND_NOT, new ConditionItem("DeptName", "like", "%部%"));
    condn.add(Condition.AND, condn1);
//    condn.add(Condition.AND_NOT, "DeptDesc", "like", "%技术%");
   
    SQL sqlStatement = sqlBuilder.
          constructSQLForSelect("departments",
                true, null, condn, null, null);
   
    System.out.println(sqlStatement.getSQLString());
    if(!"SELECT  DISTINCT * FROM departments WHERE NOT DeptName like ? AND ( DeptId != ? OR ( DeptId != ? OR DeptId Between ? AND ? ) ) ".equals(sqlStatement.getSQLString())){
      super.fail();
    }
   
    printObjects(sqlStatement.getValues());
   
    Condition userNameCDN = new Condition();
    userNameCDN.add(new ConditionItem("Users.UserId", "=", "Departments.UserId", true));
    SQL userNameSQL = sqlBuilder.constructSQLForSelect("Users", new Column[]{new Column("UserName")}, userNameCDN);
   
    Column[] columns = new Column[]{
      new Column("DeptId"),
      new Column("DeptName", "DeptName"),
View Full Code Here

   *方法测试
   */
  public void testconstructSQLForCount() {
    System.out.println("\n[正在测试方法: SQLBuilder.constructSQLForCount()...]");
   
    Condition condn = new Condition();
   
    Condition condn1 = new Condition();
    condn1.add(new ConditionItem("DeptId", "!=", "3"));
   
    Condition condn2 = new Condition();
    condn2.add(Condition.OR, new ConditionItem("DeptId", "!=", new Integer(2)));
    condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
   
    condn1.add("OR", condn2);
   
    condn.add(Condition.AND_NOT, new ConditionItem("DeptName", "like", "%部%"));
    condn.add(Condition.AND, condn1);
View Full Code Here

 
  public void testHsqlSQLBuilder(){
    System.out.println("\n[正在测试方法: HsqlSQLBuilder.constructSQLForSelect()...]");
   
   
    Condition condn = new Condition();
    condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
    condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
    condn.add(new ConditionItem("F1", "=", "1"));
    condn.add(new ConditionItem("F2", "=", "2"));
    condn.add(new ConditionItem("F3", "=", "3"));
    condn.add(new ConditionItem("F4", "=", "4"));
    condn.add(new ConditionItem("F5", "=", "5"));
    condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
   
   
    Column[] columns = new Column[]{
        new Column("DEPT_ID"),
        new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
        new Column("F1"),
        new Column("F2"),
        new Column("F3"),
        new Column("F4"),
        new Column("F5"),
        new Column("F6"),
    };
   
    /* constructSQLForSelect测试开始 */
    {
      double totalUseTime = 0;
      int count = 0;
      for(int i=0;i<2000;i++){//在此设置测试次数
          long stime = System.nanoTime();       
         
          condn = new Condition();
          condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
          condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
          condn.add(new ConditionItem("F1", "=", "1"));
          condn.add(new ConditionItem("F2", "=", "2"));
          condn.add(new ConditionItem("F3", "=", "3"));
          condn.add(new ConditionItem("F4", "=", "4"));
          condn.add(new ConditionItem("F5", "=", "5"));
          condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
         
         
          columns = new Column[]{
              new Column("DEPT_ID"),
              new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
View Full Code Here

 
  public void testMssqlSQLBuilder(){
    System.out.println("\n[正在测试方法: MssqlSQLBuilder.constructSQLForSelect()...]");
   
   
    Condition condn = new Condition();
    condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
    condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
    condn.add(new ConditionItem("F1", "=", "1"));
    condn.add(new ConditionItem("F2", "=", "2"));
    condn.add(new ConditionItem("F3", "=", "3"));
    condn.add(new ConditionItem("F4", "=", "4"));
    condn.add(new ConditionItem("F5", "=", "5"));
    condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
   
   
    Column[] columns = new Column[]{
        new Column("DEPT_ID"),
        new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
        new Column("F1"),
        new Column("F2"),
        new Column("F3"),
        new Column("F4"),
        new Column("F5"),
        new Column("F6"),
    };
   
    /* constructSQLForSelect测试开始 */
    {
      double totalUseTime = 0;
      int count = 0;
      for(int i=0;i<2000;i++){//在此设置测试次数
          long stime = System.nanoTime();       
         
          Condition condnA = new Condition();
          condnA.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=?", new Object[]{1})));
          condnA.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID in (?)", new Object[]{1, 2, 3, 4})));
          condnA.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
          condnA.add(new ConditionItem("F1", "=", "1"));
          condnA.add(new ConditionItem("F2", "=", "2"));
          condnA.add(new ConditionItem("F3", "=", "3"));
          condnA.add(new ConditionItem("F4", "=", "4"));
          condnA.add(new ConditionItem("F5", "=", "5"));
          condnA.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
         
         
          columns = new Column[]{
              new Column("DEPT_ID"),
              new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
View Full Code Here

  public void testMysqlSQLBuilder(){
    System.out.println("\n[正在测试方法: MysqlSQLBuilder.constructSQLForSelect()...]");
   
   
    Condition condn = new Condition();
    condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
    condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
    condn.add(new ConditionItem("F1", "=", "1"));
    condn.add(new ConditionItem("F2", "=", "2"));
    condn.add(new ConditionItem("F3", "=", "3"));
    condn.add(new ConditionItem("F4", "=", "4"));
    condn.add(new ConditionItem("F5", "=", "5"));
    condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
   
   
    Column[] columns = new Column[]{
        new Column("DEPT_ID"),
        new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
        new Column("F1"),
        new Column("F2"),
        new Column("F3"),
        new Column("F4"),
        new Column("F5"),
        new Column("F6"),
    };
   
    /* constructSQLForSelect测试开始 */
    {
      double totalUseTime = 0;
      int count = 0;
      for(int i=0;i<2000;i++){//在此设置测试次数
          long stime = System.nanoTime();       
         
         
          condn = new Condition();
          condn.add(new ConditionItem("DEPT_NAME", "IN", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)));
          condn.add(new ConditionItem("DEPT_NO", "IS", "NOT NULL"));
          condn.add(new ConditionItem("F1", "=", "1"));
          condn.add(new ConditionItem("F2", "=", "2"));
          condn.add(new ConditionItem("F3", "=", "3"));
          condn.add(new ConditionItem("F4", "=", "4"));
          condn.add(new ConditionItem("F5", "=", "5"));
          condn.add(new ConditionItem("F6", "in", new Object[]{"1", "2", "3", "4"}));
         
         
          columns = new Column[]{
              new Column("DEPT_ID"),
              new Column("DEPT_NAME", new SQL(SQL.SELECT, "SELECT DEPT_NAME FROM ALL_DEPTS WHERE D.DEPT_ID=C.DEPT_ID", null)),
View Full Code Here

  /**
   *方法测试
   */
  public void testGetConditionString() {
    System.out.println("\n[正在测试方法: ConditionTestCase.getConditionString()...]");
    Condition condn;
    condn = new Condition();
    System.out.println("getConditionString=("+condn.getConditionString()+")");
    assertTrue(condn.getConditionString().length()==0);
    printObjects(condn.getValues());

    condn.add(" anD ", new ConditionItem("DeptId", "=", "1"));
    condn.add(Condition.AND, new ConditionItem("DeptId", "=", "2857"));
    condn.add(Condition.AND, new ConditionItem("DeptName", "Like", "%部%"));
    condn.add(new ConditionItem("DeptId", "Between", new Object[]{"1","3"}));
    condn.add(new ConditionItem("DeptId", "IN", new Object[]{"1","2", "3", "4"}));
    System.out.println("getConditionString=("+condn.getConditionString()+")");
    printObjects(condn.getValues());

    Condition condn1 = new Condition();
    condn1.add(new ConditionItem("DeptId", "!=", "3"));

   
    Condition condn2 = new Condition();
    condn2.add(Condition.OR, new ConditionItem("DeptId", "=", "1"));
//    condn2.add(Condition.OR, "DeptId", "=", "2");
//    condn2.add(Condition.OR, "DeptId", "IN", new Object[]{"3", "4", "5"});
    condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
    System.out.println("getConditionString=("+condn2.getConditionString()+")");
    printObjects(condn2.getValues());
   
    condn1.add("OR", condn2);
   
    condn = new Condition();
    condn.add(Condition.AND_NOT, new ConditionItem("DeptName", "like", "%部%"));
    condn.add(Condition.AND, condn1);
    condn.add(Condition.AND_NOT, new ConditionItem("DeptDesc", "like", "%技术%"));
    System.out.println("getConditionString=("+condn.getConditionString()+")");
    assertEquals(condn.getConditionString().trim(), "NOT DeptName like ? AND ( DeptId != ? OR ( DeptId = ? OR DeptId Between ? AND ? ) ) AND NOT DeptDesc like ?");
    printObjects(condn.getValues());
   
    Condition deptCondn = new Condition();
    deptCondn.add(new ConditionItem("Depts.DeptId", "=", "Users.DeptId", true));
    SQL sql = sqlBuilder.constructSQLForSelect("Depts", new Column[]{new Column("DeptName")},deptCondn);
   
    condn = new Condition();
    condn.add(new ConditionItem("DeptName", "like", "%部%", true));
    condn.add(new ConditionItem("Depts.DeptId", "=", "Users.DeptId", true));
    condn.add(new ConditionItem("DeptName", "=", sql));
//    System.out.println("getConditionString=("+condn.getConditionStatement()+")");
    printObjects(condn.getValues());
   
   
    /* Condition测试开始 */
    {
      double totalUseTime = 0;
      int count = 0;
      for(int i=0;i<2000;i++){//在此设置测试次数
          long stime = System.nanoTime();       
          /* 测试代码 开始 */
         
          condn = new Condition();
          condn.add(new ConditionItem("DeptName", "like", "%部%", true));
          condn.add(new ConditionItem("Depts.DeptId", "=", "Users.DeptId", true));
          condn.add(new ConditionItem("DeptName", "=", sql));
         
          condn2 = new Condition();
          condn2.add(Condition.OR, new ConditionItem("DeptId", "=", "1"));
          condn2.add(new ConditionItem("DeptId", "=", "2"));
          condn2.add(new ConditionItem("DeptId", "IN", new Object[]{"3", "4", "5"}));
          condn2.add(Condition.OR, new ConditionItem("DeptId", "Between", new Object[]{"6", "9"}));
         
          condn1 = new Condition();
          condn1.add(new ConditionItem("DeptId", "!=", "3"));
          condn1.add("OR", condn2);
         
          condn.add(Condition.AND, condn1);
         
View Full Code Here

        new Column("RevertContent"),
        new Column("Reverter"),
      };
     
      /* 条件 */
      Condition condition = new Condition();
      condition.add(new ConditionItem("ID","=", request.getParameter("ID")));
     
      /* 构建SQL语句 */
      SQL sql = sqlBuilder.constructSQLForSelect("Messages", column, condition);
      /* 执行SQL语句,并返回结果 */
      Iterator it = ((List)sqlExecutor.execute(sql, Message.class)).iterator();
View Full Code Here

TOP

Related Classes of org.fto.jthink.jdbc.Condition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.