使用JPA重构DAO层

This commit is contained in:
myh 2023-10-25 18:10:36 +08:00
parent ccc39aed33
commit 62d95a3b6d
2 changed files with 15 additions and 6 deletions

View File

@ -1,14 +1,12 @@
package com.example.springdemo.dao;
import com.example.springdemo.entities.Merchants;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MerchantsRepository extends JpaRepository<Merchants, Long> {
List<Merchants> findByName(String name);
void deleteById(@NotNull Long id);
public interface MerchantsRepository
extends JpaRepository<Merchants, Long> {
Merchants findByName(String name);
}

View File

@ -0,0 +1,11 @@
package com.example.springdemo.dao;
import com.example.springdemo.entities.Users;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UsersRepository
extends JpaRepository<Users, Long> {
Users findByName(String name);
}