Java 数据库持久工具 timon

码农软件 · 软件分类 · ORM/持久层框架 · 2019-09-23 11:27:35

软件介绍

Timon 是基于Java的数据库持久工具, 提供SQL Maps以及SQL工具

  • 采用XML定义SQL语句

  • 支持数据库与Java对象之间的映射

  • 支持外部数据缓存,支持Ehcache,Memcached和内置同步缓存

  • 提供SQL语句解析、格式化工具

安装方式

<dependency>
    <groupId>org.pinae</groupId>
    <artifactId>timon</artifactId>
    <version>1.1</version>
</dependency>

实例代码

1. XML配置

<?xml version="1.0" encoding="UTF-8" ?>

<global key="table" value="person" />

<mapper namespaces="org.piane.timon">
    <sql name="getPerson">
        select * from :table where 1=1 
        <choose when="id">
            and id = :id
        </choose>
    </sql>
</mapper>

2.实例代码

public class SQLSessionFactoryDemo {

    public static void main(String[] args) {
        SQLSessionFactory sessionFactory = null;
        SQLBuilder builder = null;

        try {
            builder = new SQLBuilder()
            sessionFactory = new SQLSessionFactory();

            SQLSession session = sessionFactory.getSession();

            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put("id", 1);
            Person person = (Person)session.one(
                builder.getSQLByNameWithParameters("org.piane.timon.getPerson", parameters), 
                Person.class);

            session.close();

        } catch (IOException e) {

        }
    }
}

本文地址:https://codercto.com/soft/d/15218.html

计算理论导论

计算理论导论

塞普斯 / 机械工业出版社 / 2002-8 / 39.0

This book——by a noted authority and educator in the field——presents computer science theory from a uniquely intuitive,“big picture”perspective.The author grounds his clear and interesting study on ......一起来看看 《计算理论导论》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具