my batis plus Oacle 에 데이터 홈 키 를 삽입 하여 증가 합 니 다.
@Data
@TableName(value="testplus")
//
@KeySequence(value = "SEQ_TESTPLUS_ID", clazz = Integer.class)
public class TestPlus implements Serializable {
/**
*
* @TableId , , yml
* AUTO: ID
* INPUT: ID
* ID_WORKER: ID,Long
* ID_WORKER_STR: ID
* UUID: ID,UUID
* NONE:
*/
// @TableId
@TableId(value = "ID", type = IdType.INPUT)
private int id;
private String name;
private int age;
private String gender;
private double score;
}
실체 클래스 에 시퀀스 @ KeySequence (value = "SEQ TESTPLUS ID", clazz = Integer. class), @ TableId (value = "ID", type = IdType. INPUT) 설명 id 필드 를 추가 해 야 합 니 다.
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
# Sequence
global-config:
key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
application. yml 설정 파일 에 전역 설정 을 추가 하고 시퀀스 로 id 를 생 성 합 니 다.
@Mapper
public interface TestPlusMapper extends BaseMapper {
}
mapper 층
@Service
public class TestPlusServiceImpl extends ServiceImpl implements TestPlusService {
}
실현 계층
public interface TestPlusService extends IService {
}
서비스 계층
@RequestMapping(value="insert",method = RequestMethod.POST)
public String insert(@RequestBody Map paramMap){
TestPlus testPlus = new TestPlus();
testPlus.setAge((Integer) paramMap.get("age"));
testPlus.setGender((String)paramMap.get("gender"));
testPlus.setName((String)paramMap.get("name"));
testPlus.setScore((Integer) paramMap.get("score"));
boolean flag = testPlusService.insert(testPlus);
if(flag){
return " ";
}
return " ";
}
controller 층, 저 는 postman 테스트 를 사 용 했 습 니 다. testplus Service. insert (testplus) 방법 은 boolean 형식 을 되 돌려 주 었 습 니 다. ture 대표 에 게 성공 을 추 가 했 습 니 다. 실체 류 를 직접 전송 하면 데 이 터 를 추가 할 수 있 습 니 다. service, 실현 류, mapper 층 은 어떠한 방법 도 쓰 지 않 아 도 됩 니 다.처음에 학습 용 으로 쓰 였 는데, 어디 큰 신의 지적 에 맞지 않 겠 는가!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.