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
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » MoreTable 方法selectWithFun,count 使用实例
发表评论 取消回复