zoukankan      html  css  js  c++  java
  • 自定义主键生成器

    KeyGenerator表示 主键生成器

    public interface KeyGenerator {

    /**
    * 获取主键
    * @return 成功返回自定义生成的主键,否则返回""
    */
    String get();

    }

    DefaultKeyGenerator表示默认的主键生成器:sf+日期时间(精确到毫秒)

    public class DefaultKeyGenerator implements KeyGenerator {

    /* (non-Javadoc)
    * @see jcsf.jdbc.dao.KeyGenerator#get()
    */

    public String get() {
    String result = "" ;

    synchronized(this){
    long key = System.currentTimeMillis();
    result = "sf_" + String.valueOf(key);
    }

    return result ;
    }

    }

    /**
    * ID    

    自定义递增方式  customer,

    @DataField(name = "ID", dataType = DataType.VARCHAR, chinese = "ID", sequenceName = "com.sf.example.dao_9.DefaultKeyGenerator" ,incrementType = IncrementType.customer,isNullable = false, isPrimaryKey = true)
    private String ID;

    -------------------------------------------------------------------------
    ## 极客时间全网最便宜最优惠购买方式,优惠券返现 百度网盘 微信关注公众号“选门好课”
    扫描下方二维码关注我的公众号"选门好课",与我一起交流知识
  • 相关阅读:
    2021-5-14 日报博客
    2021-5-13 日报博客
    2021-5-11 日报博客
    2021-5-10 日报博客
    2021-5-8 周报博客
    团队介绍——北部大队
    周总结4
    梦断代码阅读笔记02
    周总结3
    周总结2
  • 原文地址:https://www.cnblogs.com/singworld/p/9724520.html
Copyright © 2011-2022 走看看