Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ciscopacket
- 오라클
- 자바
- javaee
- sql
- NCS
- 라우터
- cisco packet
- 데이터베이스
- 참조타입
- Oracle
- 정보처리기사
- 리눅스
- 버추얼머신
- w3school
- ospf
- 이것이 자바다
- 정처기필기
- 네트워크관리사
- VLAN
- 원형그래프
- Java
- autoset
- Cisco
- jsp
- php
- html
- jsp연결
- rinux
- 네트워크
Archives
- Today
- Total
기록해! 정리해!
JPAJarThymeleaf-2 (Member) 본문
1. Member
package com.rubypaper.board;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Entity
@Table(name="Member1019")
public class Member {
@Id
@GeneratedValue
private Long seq; // number(19,0) 정수 19자리
@Column(unique=true) // 유일키 제약조건
private String writer;
private int age;
}
2. MemberRepository
package com.rubypaper.board;
import org.springframework.data.repository.CrudRepository;
public interface MemberRepository
extends CrudRepository <Member,Long>{
}
3. MemberTest
package com.rubypaper.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.rubypaper.board.Member;
import com.rubypaper.board.MemberRepository;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MemberTest {
@Autowired
private MemberRepository memberRepo;
@Test
public void insert() {
for(int i=1; i<=3; i++) {
Member member = new Member();
member.setWriter("닭강정"+i);
member.setAge(17);
memberRepo.save(member);
}
}
}
>>
'SpringBoot' 카테고리의 다른 글
JPAJarThymeleaf-2 (동적DSL) (0) | 2022.10.20 |
---|---|
JPAJarThymeleaf-2 (Junit 연습문제) (0) | 2022.10.19 |
JPAJarThymeleaf-2 (Pageable, JPQL,네이티브쿼리) (0) | 2022.10.19 |
JPAJarThymeleaf-2 (Test) (0) | 2022.10.19 |
JPAJarThymeleaf-2 (Board, QLogin) (0) | 2022.10.19 |
Comments