代码拉取完成,页面将自动刷新
MyFat让MyBatis更胖
MyFat是MyBatis的DAO功能增强插件,利用全功能持久层工具jSqlBox来补足MyBatis的短板。
在pom.xml中加入以下内容即可,注意MyFat必须先于MyBatis加载:
<dependency>
<groupId>com.github.drinkjava2</groupId>
<artifactId>myfat</artifactId>
<version>3.0.0</version> <!--或最新版-->
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.2</version> <!--或最新版-->
</dependency>
如果在Spring环境下,则上面的第二项要改成Spring的包,如:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version> <!--或最新版-->
</dependency>
以下示例演示了myfat的基本配置和使用:
public class HelloWorld implements ActiveEntity<HelloWorld> {
private String name;
public String getName() {return name; }
public void setName(String name) {this.name = name; }
public static void main(String[] args) {
DataSource ds = JdbcConnectionPool
.create("jdbc:h2:mem:DBName;MODE=MYSQL;DB_CLOSE_DELAY=-1;TRACE_LEVEL_SYSTEM_OUT=0", "sa", "");
SqlBoxContext ctx = new SqlBoxContext(ds);
SqlBoxContext.setGlobalSqlBoxContext(ctx);
String[] ddls = ctx.toCreateDDL(HelloWorld.class);
for (String ddl : ddls)
ctx.nExecute(ddl);
new HelloWorld().putField("name", "Hello myfat").insert();
System.out.println(ctx.iQueryForString("select name from HelloWorld"));
}
}
欢迎发issue提出更好的意见或提交PR,帮助完善myfat
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。