TerminalServiceImpl.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:iris 作者:
BigInteger determineUniqueId() {

        String entityName = Terminal.class.getAnnotation(Entity.class).name();
        BigInteger nextUniqueId = uniqueIdSequenceService.getNextId(entityName);

        boolean isUniqueIdAlreadyAssigned = terminalRepository.findByUniqueId(nextUniqueId) != null;

        while (isUniqueIdAlreadyAssigned) {
            // In this loop we increment the ID by ourselves to avoid write-accesses to the DB for performance.
            LOG.warn("Terminal uniqueId {} already assigned - trying next uniqueId", nextUniqueId);
            nextUniqueId = nextUniqueId.add(BigInteger.ONE);

            if (terminalRepository.findByUniqueId(nextUniqueId) == null) {
                isUniqueIdAlreadyAssigned = false;
                uniqueIdSequenceService.setNextId(entityName, nextUniqueId);
            }
        }

        return nextUniqueId;
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号