MoreTable 方法selectWithFun,count 使用实例

205 篇文章 0 订阅

ORM Bee,

example for MoreTable methods:selectWithFun,count 

ORM Bee时, MoreTable 方法selectWithFun,count 使用实例

package org.teasoft.exam.bee.osql;

import org.teasoft.bee.osql.BeeException;
import org.teasoft.bee.osql.FunctionType;
import org.teasoft.bee.osql.api.Condition;
import org.teasoft.bee.osql.api.MoreTable;
import org.teasoft.exam.bee.osql.moretable.entity.Assignexam;
import org.teasoft.honey.osql.core.BeeFactory;
import org.teasoft.honey.osql.core.BeeFactoryHelper;
import org.teasoft.honey.osql.core.Logger;
import org.teasoft.honey.osql.shortcut.BF;

/**
 * example for MoreTable methods:selectWithFun,count 
 * @author Kingstar
 */
public class MoreTableFun {

	public static void main(String[] args) {
		test();
	}

	public static void test() {
		try {
			MoreTable moreTable = BeeFactory.getHoneyFactory().getMoreTable();
			Condition distinctCondition0 = BeeFactoryHelper.getCondition();
			distinctCondition0.selectDistinctField("assignexam.id")
			//	.selectFun(FunctionType.MAX, "assignexam.id")
			//	.selectField("assignexam.id")
			;
//			 List<Assignexam> list=moreTable.select(new Assignexam(), distinctCondition0);
//			 Printer.printList(list);
			 
			 //V2.4.0
			 Condition funCondition =BF.getCondition();
//			 funCondition.selectFun(FunctionType.COUNT, "Assignexam.id", "count1");
//			 funCondition.selectFun(FunctionType.MIN, "Assignexam.id", "count1");
//			 funCondition.selectFun(FunctionType.COUNT, "*", "count1");
			 funCondition.selectFun(FunctionType.COUNT, "*");
			 String fun0= moreTable.selectWithFun(new Assignexam(),funCondition);
			 Logger.info(fun0);
			 
			 funCondition.selectFun(FunctionType.COUNT, "*");
			 String fun= moreTable.selectWithFun(new Assignexam(),BF.getCondition().selectFun(FunctionType.MAX, "Assignexam.id"));
			 
			 int fun2= moreTable.count(new Assignexam());
			 Logger.info(fun2);
			 
			 int fun4= moreTable.count(new Assignexam(),BF.getCondition());
			 Logger.info(fun4);
			 
//			 moreTable.selectWithFun(new Assignexam(),BF.getCondition()); //test exception
//			 Condition c3=BF.getCondition();
//			 c3.selectFun(FunctionType.COUNT, "*");
//			 c3.selectFun(FunctionType.MAX, "Assignexam.id");
//			 moreTable.selectWithFun(new Assignexam(),c3);  //test exception

		} catch (BeeException e) {
			e.printStackTrace();
			Logger.error("In MoreTableFun (BeeException):" + e.getMessage());
		} catch (Exception e) {
			Logger.error("In MoreTableFun (Exception):" + e.getMessage());
			e.printStackTrace();
		}
	}

}

日志:

[Bee] LoggerFactory Use the Logger is : org.teasoft.honey.logging.SystemLogger
[Bee] The current Level in SystemLogger is :debug
[INFO] [Bee] ========= BeeInitPreLoadService initLoad...
[INFO] [Bee] ========= Preload class PreLoadInit, load...
[INFO] [Bee] ========= Preload class ExtPreLoadInit, load...
[INFO] [Bee] -------- Bee    2.4.0 -------- 
[INFO] [Bee] -------- Honey  2.4.0 -------- 
[INFO] [Bee] -------- BeeExt 2.4.0 -------- 
[DEBUG] [Bee] ========= Bee    buildId  2.4.0.6
[DEBUG] [Bee] ========= Honey  buildId  2.4.0.6
[DEBUG] [Bee] ========= BeeExt buildId  2.4.0.6
[DEBUG] The name is '*' , does not conform to naming conventions!
[INFO] [Bee] ========= get the dbName via url is: MySQL
[WARN] Do not set the database info: bee.db.driverName do not config; 
[DEBUG] Use OriginalConn!
[INFO] [Bee] select SQL: select count(*) from assignexam,assigncourse where assignexam.classno=assigncourse.classno and assignexam.term=assigncourse.term and assignexam.subjectno=assigncourse.subjectno
[INFO] 2
[DEBUG] The name is '*' , does not conform to naming conventions!
[INFO] [Bee] select SQL: select max(Assignexam.id) from assignexam,assigncourse where assignexam.classno=assigncourse.classno and assignexam.term=assigncourse.term and assignexam.subjectno=assigncourse.subjectno
[DEBUG] The name is '*' , does not conform to naming conventions!
[INFO] [Bee] ==========get from Cache.
[INFO] [Bee] select SQL: select count(*) from assignexam,assigncourse where assignexam.classno=assigncourse.classno and assignexam.term=assigncourse.term and assignexam.subjectno=assigncourse.subjectno
[INFO] 2
[DEBUG] The name is '*' , does not conform to naming conventions!
[INFO] [Bee] ==========get from Cache.
[INFO] [Bee] select SQL: select count(*) from assignexam,assigncourse where assignexam.classno=assigncourse.classno and assignexam.term=assigncourse.term and assignexam.subjectno=assigncourse.subjectno
[INFO] 2

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值