Java工程结构图
maven工程,可参考:
bee.properties
#bee.db.dbName=MySQL #bee.db.driverName = com.mysql.jdbc.Driver bee.db.url =jdbc:mysql://localhost:3306/bee?characterEncoding=UTF-8 bee.db.username =root bee.db.password =
BeeTest.java
/* * Copyright 2016-2021 the original author.All rights reserved. * Kingstar(honeysoft@126.com) * The license,see the LICENSE file. */ package org.bee.exam; import java.util.List; import org.bee.exam.entity.Orders; import org.teasoft.bee.osql.Suid; import org.teasoft.honey.osql.core.BeeFactoryHelper; /** * @author Kingstar * @since 1.9 */ public class BeeTest { public static void main(String[] args) { Suid suid = BeeFactoryHelper.getSuid(); Orders orders1 = new Orders(); orders1.setName("Bee(ORM Framework)"); List<Orders> list1 = suid.select(orders1); //select for (int i = 0; i < list1.size(); i++) { System.out.println(list1.get(i).toString()); } } } //注意: 事务,分页,排序,范围查询,查询结果直接返回json等都支持,这里只是一个入门例子. //更加应用参考,请查看官网: 更多例子 和 综合应用 . //https://github.com/automvc/bee //https://gitee.com/automvc/bee
表orders对应的实体Javabean–Orders.
package org.bee.exam.entity; import java.io.Serializable; import java.math.BigDecimal; /** *@author Honey *Create on 2020-10-01 12:41:06 */ public class Orders implements Serializable { private static final long serialVersionUID = 1593472489996L; //time-->String private Long id; private String userid; private String name; private BigDecimal total; private String createtime; private String remark; private String sequence; private String abc; private String updatetime; //...get,set public String toString(){ StringBuffer str=new StringBuffer(); str.append("Orders["); str.append("id=").append(id); str.append(",userid=").append(userid); str.append(",name=").append(name); str.append(",total=").append(total); str.append(",createtime=").append(createtime); str.append(",remark=").append(remark); str.append(",sequence=").append(sequence); str.append(",abc=").append(abc); str.append(",updatetime=").append(updatetime); str.append("]"); return str.toString(); } }
运行结果:
Orders[id=637266389106717,userid=bee,name=Bee(ORM Framework),total=91.990000,createtime=null,remark=null,sequence=null,abc=null,updatetime=null] Orders[id=637266389106743,userid=bee,name=Bee(ORM Framework),total=91.990000,createtime=2021-10-25 12:29:16,remark=null,sequence=null,abc=null,updatetime=null] Orders[id=637266389106744,userid=bee,name=Bee(ORM Framework),total=91.990000,createtime=null,remark=null,sequence=null,abc=null,updatetime=null]
查询订单表数据:
关键语句只要两句就搞定.
Suid suid = BeeFactoryHelper.getSuid();
List<Orders> list1 = suid.select(orders1);//select 查询订单表数据
配置,只需要将数据的连接, 用户名,密码等信息写在bee.properties即可.
如此简单, 在于一个, 该框架帮我们处理了许多对数据库的固定操作,让我们从操作DB的繁杂步骤解放出来,尽快进入到业务逻辑的开发中.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/291502.html