Skip to content

jdbcService

nimamoosavi edited this page Aug 25, 2021 · 3 revisions

this interface is the implementation of JpaRepository of Spring Data And JPA and generic specifications of Spring Data JPA to query any parameter, you can find know about it in {@link <a https://spring.io/projects/spring-data-jpa} you must create an interface and extended of it then generate a bean of your interface and use all method that Spring Data implement it And then you Access the Spring Data Query Method and Used It in your Interface

List<Map<String, Object>> queryForList(String sql, MapSqlParameterSource sqlParameterSource)

sql is the native query for execute in Data Base

sqlParameterSource is the parameter source for execute parametric

return List<Map < String, Object>> of the result of database

List queryForList(String sql, MapSqlParameterSource sqlParameterSource, Class tClass)

sql is the native query for execute in Data Base

sqlParameterSource is the parameter source for execute parametric

tClass the class you want cast it

return List the object that cast it

List queryForList(String sql, int queryTimeOut, Class tClass)

sql is the native query for execute in Data Base

queryTimeOut is the time that you want method wait for response

tClass the class you want cast it

return List the object that cast it

List<Map<String, Object>> queryForList(String sql, int queryTimeOut)

sql is the native query for execute in Data Base

queryTimeOut is the time that you want method wait for response

return List<Map < String, Object>> is the result of data Base

T query(String sql, MapSqlParameterSource sqlParameterSource, Class tClass)

sql is the native query for execute in Data Base

sqlParameterSource is the parameter source for execute parametric

tClass the class you want cast it

return the single result that result from data Bas

you must know that if the result not been single the methode throw Runtime Exception

T query(String sql, int queryTimeOut, Class tClass)

sql is the native query for execute in Data Base

queryTimeOut is the time that you want method wait for response

tClass the class you want cast it

return T is the Object of result from database

Map<String, Object> query(String sql, MapSqlParameterSource sqlParameterSource)

sql is the native query for execute in Data Base

sqlParameterSource is the parameter source for execute parametric

return Map<String, Object> the result of Data base

you must know if the result not been single the methode throw Runtime Exception

int maxRows()

return the number of max rows in table

int queryTimeOut()

return the default Time out of Connection

int queryTimeOut(NamedParameterJdbcTemplate namedParameterJdbcTemplate)

namedParameterJdbcTemplate is the Object of Spring that you must use it for execute query

return the Object Time out of Connection

int queryTimeOut(JdbcTemplate jdbcTemplate)

jdbcTemplate is the Object of Spring that you must use it for execute query

return the Object Time out of Connection

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 SpringJpa

T update(T t)

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

the Entity that save it in database

this method used SpringJpa

List saveAll(List tList)

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

return the List Of Entity and their Ids

this method used SpringJpa

Optional findById(I id)

id the incrementalId of database Object

return the Entity that save it in database

used for fetch Data By IncrementalId And this method used SpringJpa

List findAll()

return the List Of Entities

this method used SpringJpa

List findAll(Query query)

query is the criteria for find in where Clause

return the List Of Entities

PageDTO<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

PageDTO<List> findAll(int page, int pageSize, Query query)

page the page number that you must fetch it

query is the criteria for find in where Clause

pageSize the page Size of that you need to split Data

return the Optional List Of Entity from Response Of Data Base

long count()

return the Number Of data

long count(Query)

query is the criteria for find in where Clause

return the Number Of data

void deleteById(I id)

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

throws RuntimeException has throw if Delete Method Not Acceptable

Clone this wiki locally