Skip to content

GeneralRepository

seyyed edited this page Aug 5, 2021 · 1 revision

GeneralRepository

this interface used for connect crud to database and implement in jdbc client Project and Mongo client project and micro client Project you must add the project to your pom file and use Repository layer

method

T save(T t);

t the Entity View Model that you must Add To Data Base

return the Optional Of Entity that save it in dataBase

this method used for save Data in Data base

T update(I id, T t)

id the incrementalId of dataBase Object

t the Entity View Model that you must Add To Data Base

return the Optional Of Entity that save it in dataBase

this method used for Update data Base Object

List saveAll(List tList)

tList the list of Entity that you must save it in Data base

return the Optional List Of Entity and their Ids

used for save the batch of Data in Data base

Optional< T > findById(I id)

id the incrementalId of dataBase Object

the Optional Of Entity that save it in data base

used for fetch Data By IncrementalId

List findAll()

return the List Of Entities

this methode uses for Fetch All Data

List findAll(int page, int pageSize)

page the page number that you must fetch it

pageSize the page Size of that you need to split Data

return the Optional List Of Entity from Response Of Data Base

List findAll(int page, int pageSize, List< Sorts > Sorts)

return the Number Of data

method used for get the count Of Data

void deleteById(I id)

id is the incrementalId of Object that you need too remove it from Data Base

throws RuntimeException has throw if Delete Method Not Acceptable

Used for delete Object From Incremental Id

Example

used for jdbc project for implement general Repository layer

@Service
public class AffairJdbcService extends JdbcServiceImpl<Affair, Long> {
}

@Repository
public interface AffairRepository extends JdbcRepository<Affair, Long> {
}
Clone this wiki locally