关于项目中根据当前数据库中最大ID生成下一个ID问题——(五)
1.关于部门管理时候根据上级产生下级部门ID的问题(传入一个参数是上级部门id)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaUAAAB3CAIAAAAsMchpAAAXSklEQVR4nO1d32vdRr7//jFl95K1obGx4B6WwsLlgumLDXvbZI+pjRYU6Isx7EtpU05wsasHL3rZl73x3dh+aU5SkYcgsqXJknTd4rROGm2Cm2obgoNh2UJy3J73cx9GGn1nNNLRsSXNkWY+fAk6X41G853vZ77zSxnD3pe3sPR6vStXrly5cqXX6+19eav/9fs1Fc4QLbUQBb2moMkSBe5/9RkWrvZ/3r9UU9E0qqMo6DUFTZYo8PXe51j4ePfw45qKplEdRUGvKWiyRIH9+3ewcLX/k//H0eTmnAH/eX1Yso9fhxivz3F3r/8WIEcm2XJaGnUvTMKsk5lmZQIAzqx0SWIAAJi4IN2jtZYTe21lgjjgzMpGPl/k8C/KVpyhMweQI5MTm1xI/kMkXz2U9XjlAg++uYuFj3eP/3Ra8X5r/M+7wlsfv/7r6ylPZdzKKcV3m90Lk3OrrHJ1fuIMVa5M1Mnx4ymn8NrqPIpHJ/GFwL/Dczu907NNHhdSpVdOvQS+3f8CC1f7198CgDeuH1w+/vMbAABnzx0fXH743msArxlnSa/32vpfLx8fXD4+uHz9LaJ54/pBqAmfonhr+ZjeOri8fhalxInfWuZvjS6cIXFXuTFL++pPl88AnJmkQ4NuWCnOHNEgqpGnKELfr85PXHDmwgcpNT9dPsOOCFbn0YPxqBCnRG9XWfJ4bWUCYOJC5COY37hFfUHzIb44tX+Z3PaSiedWS4l3ovzFVKETC5idjEtC+XZmfm52pUs1dPAbpkzWg7huUypHUI1MkTDJBV6QIvDo4S4WrvaPn26vn/3N9afbx0+3j5/+Yels+/jp9vHT7etvA7z9h+On28f/+5vwIhKUfvv46fbxZ22DTSBO+VnbgPDn9bcBgM1kdEnSaAUTImobzlzkv43ZISwXj+8uUH2cfmOVcnRyeTMiwazz5a2VCZhc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ll2wAqBpVEco6DUFTZaF1PONcSLfNgzb7/f7tgEAhu33+75tkP+fYtjxlRtf0vsAYLpxPkllv9/vuybJv1gkaVRTQ5SCgl5T0GRZSD3fGKVxzbiuXNMwjOiXHV65pmHT1LaBE9t9HilK1h2FIEGjuhqiFBT0moImy0Lq+cZxEqZmXNOwad9QXO33XRMK73B4GtXWEKWgoNcUNFkWUs83pinYenFNw+77YQ0XWPtl9DccjepriFJQ0GsKmiwLqecb0xS2gaslrDvS4RRc+0L9KcDRqL6GKAUFvaagybKQer4xTSGsfdLhjFD78fqoUCkt3tXCEKWgoNcUNFkWUs83pikEo+voiq6jxkNjH1X+qLVf/Xy2JoYoBQW9pqDJspB6vnGcBNUL2v0me92oYwF0i90IpzeEysRLCkPGMnC9DFEKCnpNQZNlIfV8Y5Smgpqp/nuUkqAmi4qEgl5T0GRZ+H/6XMWX9vcKIwAAAABJRU5ErkJggg==" alt="" />
两种解决方案:
第一种: 在数据库就生成加一后的字符串
1.
SELECT MAX(unitId+1) FROM t_unit_base_info WHERE upUnitId=''
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAjCAIAAADXIUXhAAAE3UlEQVRoge2Z0UsbSRzHf39KC2oL5cCNcaAgAUEEEQ4P2iQ1hG6Q88EXX6RFpUEbzhV6CPdgBd0zRx5OYpYjDxJasVekd63amlQvklohCHJwuYdzNnfvdw+zu5md2UxT3YQD98f3YeY7v/nNbD6awP7gBy9aG/86BWAuSDbve3H5qIth9/UzWpjCsPv62T9vpz25JRGGvTebtBgMf+/PenJLIgxvd7dosRgK857ckgjD/t7PtBgMMQDoHKoeLhDNdwJ0DlU3hhCQuDa/QS0BoAdT1jj2dMHaWD1cKDy4RlY/WxtDCG5rn0ojhxpB3ZlIuwPwiSJfx4DLeXr7gnd2kghD/t02LQZDdakHdV6PLS1Wi4u2cXGx8PB67G4PejhDptXiWAx6tKKZWfO51csrdwfdHXNcmu+sewqzxE0htsRvd/PaIgzv91/RYjDoywEUDK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ywOAAAvbqRmu3hxQ74qD9SEqw3k1GwXysQRZMGuCwr2gYg6nubtD1Ew4ukSdozBivwN+WpD3nnIeaYNR1RmlptENYEoIg4AeYQ4AHqRH8p4et2m0M9mEtlMwkh/bZB7siwXopG1gFyIpp7c4teiciEqOIhOHWNyISoXovLaIDjG5EKAh8EIimgWHIA2alOcEOC17ZEHt4S3xmBFflQuROW3Y9yDgKw/ojITd6vWJLtSW6VtpwfrMYV+LnuSy54Y6YeGuMCP8nUMORW4zYdi8u44NzqPg5HR28JuTL6e52EogoKhIXCM4wT5OhYZBbKO4EBbYoIDcKZWJyZfz/P67YJDq4y8O86pCfM8AB+qkkn2GRoCIJZCQ0B8hKoHVQ/WYwr9fC6Vz6UM9HvRt9srfPzwetOr/3HqgnfI4LPu8lh1eNg4BQCA3rkJHgC8QmoOVRje/CDw5VLaWNWdZ3tqBdxM71wYRdRDkbonDGkAw73dujgffl3uR/Oz7uFN3ZQ8XbdUh2n0z/Nn5/kzA/2Pv/3aIL/g4evNhlX7TzZDo395/v7y/L2B/p+/Jxrl5NOvep/+0sCC9fvnbyzphEb/6jJ3dZkz0v/jjLlRptEn34KyN8xNUlX6+PU/MDVTjL6V+sSTByUVmRotGn18BcPoN0k0+vgKhtFvkqj0tSuY9qO/7gMA8K2bRQ1xs2Ct22n08RVMu9EP9oBvvRjs0eE7RNFisbju6wkeUoK1b6fS165g2o0+kgEfMV339QQpwdq30+jjKxhG3zDFY9Ng7dup9LUrGEa/2Hr6+AqG0S+2/smDr2AY/WKxeBj0qX+W5ZF5sPbtVPraFUy70Q/2kC8CNIiHONxT5mwWrH07jT6+gmk3+i0Tlb52BcPoN0k0+vgKhtFvkqj0tSsYRr9Jov7r6t8wMzVJ5vTZ7UprZE7fNMrUGjH6VorRt1KMvpVi9K0Uo2+lGH0r9S9Cu2bY5Pbo/gAAAABJRU5ErkJggg==" alt="" />
第二种:在数据库查出当前最大值后在service层加一作为下个添加的ID
数据库查询当前最大值:
SELECT MAX(unitId) FRO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QSV9zkwAgFrKBID6CZcyK1MfuRMj0unJ9kbE8m6whnfo8NlQa6w7N26fAgCAb3FWBICItL9IOoxvnEhiq5Ux1nXn2V96B/MwvsUcSfRNiYZmbWUA474hSy7mtlvnuYSZmZ5+eueSfxPh5w3Xuv2PDsPM9Ovn92557+lPvqevXGzYu1/+4uJJ2Jl++cjd2WxMuRyqC9NsNgtc7OJM3VeXZ58UqVzO1J0p+aTPmTpXd6bkkz5n6lwOmBrf81VVVdV8FAAgmrd2Iaktdx6mvOeE11fdmTYOlkymKS9E82rKa/nxuyRVVTUf9aZ2ewj1cT76fVB1wPRw2fbs25hS03zUm2INKbz2ztdU3ZlqVdkx09bYeWi5T6HF9/rKAdNa7kqZtv7Ggtfr/TGY4qPClT77tH6UZx/XS52Z7qai+s3VGjGEVJ/v4i51xPS4TL/3KRlkd82YYuI4pLP/8pdfnbozPT3Z5v/zM8kB00/vOFMmdWf69fN7zpRJDph++ciZMsnBO8r41sfFpE5M+Tfp3tSJaYc1rt7EmbovztR9cabuizN1X/8ClD7JAHMdG34AAAAASUVORK5CYII=" alt="" />
Service层加一
String nextId = unitMapper.getNextUnitId(upUnitId);
if (nextId == null) {
nextId = upUnitId + "001";
} else {
nextId = Integer.toString(Integer.parseInt(nextId) + 1);
}
2.关于带有字母的ID自动生成问题
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAACyCAIAAAAyDF1LAAAJ8UlEQVR4nO2d0WsbRx7Hf39MSA96hUhGCyeOQqAUTF5y0EukuDhCAT3k4cLBvbixggPBiuhx6B6Og6vVuCocdmyEH5alF6KU0Gt7Thu71iW4rmxjYgJHBPb6uu97D7Mz+5vVT3JixbuT8+/L4M7+Zmdm9dGsdvrjywZc13Vdd3Z2dnZ21j3x6uUAy998gRuWv/nC++76ySwRDqLAo2/vRRp+fnzzZBYa0HfL96OAVm+fzEIDevzoQaThv+0/HVexz1vwq8Uj9b19BkKdOR9pXfwA4KgjqxLhUDsPAKOw8v3DKKAnfx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jPYqBwpmPFwYltA9ijyIlYqPIHkUsAhB7FLEIQOxRxCIAcboDiwDEGcXB4oyiJpuT9oNFAGKPIhYBiD2KWAQgozyKHWSTSMS9YBvuUezUssm4OqTsXn+QUR5FEwEZ5VHEt1giJkUCkKEexYRMigQg9ihiEYAM9Sh2aln2KLJH8c0TsVFkjyIWAYg9ilgEIPYoYnG64xARgDijOFicUdRks0dxsGz2KA4WAYg9ilgEIAM9iqFFMPZXKdrmexSrVkLvmPQ87w3wKEYNnXGLAGSUR7FdLRaLFn3jxSICkGEeRUVGWbxiFQHIKI9isxj+ACVytxGAzPIoShuw53nNYpKvCTTXoxiGk/gRQvsg9ihSIjaK7FHEIgCxRxGLAMQeRSwCEKc7sAhAnFEcLM4oarI5aT9YBCD2KGIRgNijiEUAMsmjKAPEuTHJNtujiIxCnUTsQcZ7FJUS4mO8R7HfXLGJAGSiRzGp9fPGeBR1J2CcIgCZ5FEMlBwf8z2K4tqSsG8KoX0QexQpERtF9ihiEYDYo4hFAGKPIhanOw4RAYgzioPFGUVNNnsUB8tmj+JgEYDYo4hFADLMo5jk25U88z2KynTSrlqJePHsXn+QUR7FkFVC/5YxAcgoj2L/F5vFJAKQUR5FZDYTLsC4RQAyyqOoBQ25xYzyKCIqyQIy1qMoZyX2FLEI7YPYo0iJ2CiyRxGLAMQeRSwCEHsUsQhAnO7AIgBxRnGwOKOoyeak/WARgNijiEUAYo8iFgHIJI+inJSaKx7ZZnsU0WsCzfmHaI3yKGJnkCkveTPKo6itoCReY0YAMsyjqKzS2WwSL+UkAJnoUaSmi0cEIAM9in5yL3VVj3lDPYo4dswoaKF9EHsUKREbRfYoYhGA2KOIRQBijyIWpzsOUS+g/wEXN3lumoSMEgAAAABJRU5ErkJggg==" alt="" />
1.第一种:(长度定死,数据库直接加一)
SELECT CONCAT(SUBSTR(MAX(meetingId),1,1),SUBSTR(MAX(meetingId), 2) + 1) FROM t_meeting_base_info;
2.第二种:
同上面一样,在数据库中查出当前最大值后,在Service层加一
关于项目中根据当前数据库中最大ID生成下一个ID问题——(五)的更多相关文章
- 在mysql数据库中创建Oracle数据库中的scott用户表
在mysql数据库中创建Oracle数据库中的scott用户表 作者:Eric 微信:loveoracle11g create table DEPT ( DEPTNO int(2) not null, ...
- Oracle中查询当前数据库中的所有表空间和对应的数据文件语句命令
Oracle中查询当前数据库中的所有表空间和对应的数据文件语句命令 ------------------------------------------------------------------ ...
- 微软BI 之SSIS 系列 - 在 SSIS 中导入 ACCESS 数据库中的数据
开篇介绍 来自 天善学院 一个学员的问题,如何在 SSIS 中导入 ACCESS 数据表中的数据. 在 SSIS 中导入 ACCESS 数据库数据 ACCESS 实际上是一个轻量级的桌面数据库,直接使 ...
- CODESOFT中怎样打印数据库中的特定数据?
CODESOFT可用于打印.标记和跟踪的零售库存标签软件,每种产品的售卖都代表着需要打印大量的条码标签.通常我们采用的方法就是在CODESOFT连接数据库批量打 印.但是如果数据量很大,该如何选择 ...
- 在JSP中上传图片到数据库中
第一步:建立数据库 create table test_img(id number(4),name varchar(20),img long raw); 第二步:(NewImg.html) <h ...
- Eclipse中java向数据库中添加数据,更新数据,删除数据
前面详细写过如何连接数据库的具体操作,下面介绍向数据库中添加数据. 注意事项:如果参考下面代码,需要 改包名,数据库名,数据库账号,密码,和数据表(数据表里面的信息) package com.ning ...
- Oracle数据库中实现mysql数据库中auto-increment功能
在Mysql数据库中,想要实现一条数据的自增一功能(即插入此数据时填写null即可,系统自动+1),可直接在所在列使用语句auto-increment. id int primary key auto ...
- java中访问mysql数据库中的表结构信息
package cn.hncu.meta; import java.sql.Connection;import java.sql.DatabaseMetaData;import java.sql.Re ...
- PHP中实现在数据库中的增、删、查、改
其实要想在PHP中访问并获取到数据库中的数据其实并不难,下面我以例子为大家介绍: 首先,打开PHP软件和WampServer服务,确保在WampServer中的phpMyAdmin中有你要使用的数据表 ...
随机推荐
- linux 进程guanl管理的常用几个命令
执行中的程序在称作进程.当程序以可执行文件存放在存储中,并且运行的时候,每个进程会被动态得分配系统资源.内存.安全属性和与之相关的状态.可以有多个进程关联到同一个程序,并同时执行不会互相干扰.操作系统 ...
- mybatis中@Param的使用
@Param:当映射器方法需要多个参数时,这个注解可以被用于:给映射器方法中的每个参数来取一个名字.否则,多参数将会以它们的顺序位置和SQL语句中的表达式进行映射,这是默认的. 语法要求:若使用 ...
- 【bzoj2780】 Sevenk Love Oimaster
http://www.lydsy.com/JudgeOnline/problem.php?id=2780 (题目链接) 题意 给出很多主串和很多询问串,求一个询问串在多少主串中出现过 Solution ...
- Solr7.2的安装与使用
单机安装Solr服务: https://www.cnblogs.com/LUA123/p/7906774.html extend: install_solr_service.sh 参数说明: 安装脚本 ...
- (转)教你完全理解IO流里的 read(),read(byte[]),read(byte[],int off,int len)以及write
背景:对于IO部分,总是感觉很虚,不能很好的理解其中的要义,其实仔细分析,掌握其中的规律,一切都会看起来十分的自然. 1 理解 1.1 从头总结 长期以来,java中的InputStream Outp ...
- Socket通信的简单例子
客户端代码: package com.bobohe.socket; import java.io.*; import java.net.*; public class TalkClient { pub ...
- R语言 线性回归
0 引言 初学者,对于一些运行结果不是很清楚,所以看了一些课本和资料,这里做一个记录而已. 1 线性回归模型的结果分析 结果的解释: “call”:指出线性回归的公式 “Residuals”:之处从实 ...
- 题解【51nod 1290 Counting Diff Pairs】
Description 求区间内有多少对 \((i,j)\) 满足 \(|a_i - a_j| \leq k\) Solution 可以莫队做(万能的莫队) 只需要考虑加入一个数会产生多少贡献即可 离 ...
- Linux运维七:网络基础
1:网线 2:交换机,路由器 交换机(Switch)意为“开关”是一种用于电(光)信号转发的网络设备.它可以为接入交换机的任意两个网络节点提供独享的电信号通路.最常见的交换机是以太网交换机.其他常见的 ...
- Linux设备驱动之Ioctl控制
大部分驱动除了需要具备读写设备的能力之外,还需要具备对硬件控制的能力. 一.在用户空间,使用ioctl系统调用来控制设备,原型如下: int ioctl(int fd,unsigned long cm ...