JPA _INSERT_example

538 ワード

@Autowired


private UserRepositoryuserRepository;


userRepository.save(user);


INSERT!


Controller.java

	@Autowired
	private UserRepository userRepository;


	@PostMapping("/dummy/join")
		public String join(User user) {
			
			user.setRole(RoleType.USER);
			System.out.println(userRepository.save(user));
			userRepository.save(user);
			return"회원가입이 완료되었습니다.";
			
			
		}

userは受け入れて、(enum)roleは単独で参加します!