<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          JdbcPlusjdbcTemplte數(shù)據(jù)庫增強工具

          聯(lián)合創(chuàng)作 · 2023-09-28 11:32

           

          jdbcPlus

          簡單的數(shù)據(jù)庫操作.
          支持mysql.
          依賴spring-jdbc.

          配置:

          繼承自 JdbcTemplate, 不需要額外配置
          
          import java.util.Date;
          import com.github.hjx601496320.jdbcplus.annotation.Id;
          import com.github.hjx601496320.jdbcplus.annotation.Column;
          import com.github.hjx601496320.jdbcplus.annotation.Table;
          
          // 表示一張表 value為數(shù)據(jù)庫表名
          @Table(value="user")
          public class User {
          
              @Column(value="name")
              private String name;
          
              // 表示一個id(一個class限制一個id)
              @Id 
              // 表示一個字段 value為數(shù)據(jù)庫字段名
              @Column(value="id") 
              private int id;
          
              @Column(value="age")
              private int age;
          
              @Column(value="mark")
              private String mark;
          
              @Column(value="create_date")
              private Date createDate;
          
              @Column(value="status")
              private int status;
              ...
              get...
              set...
          }
          
          /*
                      數(shù)據(jù)庫操作
          操作對象 User.class, User需要添加注解@Table("user")注解值為數(shù)據(jù)庫表名稱
          屬性上添加@Column("anInt") 表示為一個數(shù)據(jù)庫字段, 注解值為數(shù)據(jù)庫字段名稱
          表示id 的屬性上需要添加@ID 注解
          每個表只支持一個id字段
          /*
          
          /**********插入數(shù)據(jù)**********/
          //插入單條記錄
          jdbcTempltePlus.insert(User user);
          //插入多條數(shù)據(jù)(拼接sql形式)
          jdbcTempltePlus.insertBatch(User.class, list);
          
          /**********查詢數(shù)據(jù)**********/
          //查出所有的User
          jdbcTempltePlus.simpleDao.select(User.class)
          //查出id為12的數(shù)據(jù)
          jdbcTempltePlus.selectById(User.class, "12");
          
          //查出所有的user_name 等于 "123" 的數(shù)據(jù),user_name 為數(shù)據(jù)庫字段名稱
          jdbcTempltePlus.selectBy(User.class, "user_name", "123");
          
          //查出所有的name 等于 "123" 并且 age 等于"18" 的數(shù)據(jù)
          //查詢條件中的 參數(shù)可以是添加了 @Column 的屬性名稱 此處 user_name 等效與 name
          jdbcTempltePlus.selectBy(
                          User.class,
                          "name", "123",
                          "age", "18"
                  );
          
          ...其他的數(shù)據(jù)庫操作請看單元測試...

          瀏覽 21
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  91麻豆精品在线观看 | 久久久精品国产 | 亚洲视频免费 | 777777欧美 | 欧美一二|