0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SpringBootAdvent Calendar 2023

Day 6

【VSCode+SpringBoot】SpringBootでAPIを作る⑥

Posted at

前回↓

はじめに

今回はRepositoryを作っていきます

Repository作成

Repositoryはデータアクセスを抽象化し、オブジェクトの集合へ格納・取得・検索するかのような振る舞いを提供します
demo直下にrepositoryフォルダを作成してその中にPersonRepository.javaを作成します

src/main/java/com/example/demo/repository/PersonRepository.java
package com.example.springbootpostgresql.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import com.example.springbootpostgresql.model.Person;

@Repository
public interface PersonRepository extends JpaRepository<Person, Integer> {
    
}

✨解説

@Repository
データ層のクラスに付与します
データベースにアクセスするために定義します

おわりに

今回はRepositoryを作成しました
次回はServiceを作成したいと思います

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?