spring-data-jpa

@ResponseBody returns empty object

六月ゝ 毕业季﹏ 提交于 2021-01-05 00:48:07
问题 When I use below to get the user object it works just fine. @GetMapping("/findOne") @ResponseBody public Optional<AppUser> findOne (Long id) { return appUserRepository.findById(id); } Above gives me a response back as: {"id":1,"useruuid":"863db606-9af6-48a8-963a-07b9fe0fc4fc","useremail":"user1@mydomain.com"} Now, I am trying to search based on UUID(4) using this: @GetMapping("/findOneUsingUUID") @ResponseBody public AppUser findOne (String useruuid) { return appUserRepository.findByUseruuid

Implement JPA Projection with count

删除回忆录丶 提交于 2021-01-04 18:58:09
问题 I want to implement JPA Projection with count. I tried this: @Query(value = "SELECT new org.service.PaymentTransactionsDeclineReasonsDTO( id, count(id) as count, status, error_class, error_message) " + " FROM payment_transactions " + " WHERE terminal_id = :id AND (created_at > :created_at) " + " AND (status != 'approved') " + " GROUP BY error_message " + " ORDER BY count DESC", nativeQuery = true) List<PaymentTransactionsDeclineReasonsDTO> transaction_decline_reasons(@Param("id") Integer

Spring data repository sends null as bytea to PostgreSQL database

守給你的承諾、 提交于 2021-01-02 05:11:25
问题 After switching from MySQL to PostgreSQL I found out that my SQL query (@Query in spring data repository interface) does not work anymore. The issue is caused by null value being sent as bytea and I'm getting following exception: Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = bytea Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Repository with @Query: public interface WineRepository extends

Spring Data JPA Pagination (Pageable) with Dynamic Queries

笑着哭i 提交于 2020-12-29 05:16:04
问题 I have a simple query as follows "select * from USERS". I also use Pageable to enable pagination. This query may have optional predicates based on the given parameters being null or not. For example if "code" parameter is given and not null, then the query becomes "select * from USERS where code = :code"; As far as I know I cannot implement this using @Query annotation. I can implement a custom repository and use EntityManager to create a dynamic query. However, I am not sure how I can

How do you handle with bulk deleting by an array of IDs in Spring Data JPA?

折月煮酒 提交于 2020-12-28 06:59:47
问题 Now I have a class User, I get a request data of an array from the jsp or html . list this Integer[] arr=[5,6,9,10,62,52,21] and then I use two methods to finish bulking deleting action. @Transactional @Override public void deleteUser(Integer id) { oneRepository.delete(id); } @Transactional @Override public void deleteSomeUser(Integer[] ids) { for (Integer id : ids) { deleteUser(id); } } I want to know that if it's a more efficient method to finish this action. you can see my logs: it seems

How do you handle with bulk deleting by an array of IDs in Spring Data JPA?

别说谁变了你拦得住时间么 提交于 2020-12-28 06:56:40
问题 Now I have a class User, I get a request data of an array from the jsp or html . list this Integer[] arr=[5,6,9,10,62,52,21] and then I use two methods to finish bulking deleting action. @Transactional @Override public void deleteUser(Integer id) { oneRepository.delete(id); } @Transactional @Override public void deleteSomeUser(Integer[] ids) { for (Integer id : ids) { deleteUser(id); } } I want to know that if it's a more efficient method to finish this action. you can see my logs: it seems

How do you handle with bulk deleting by an array of IDs in Spring Data JPA?

青春壹個敷衍的年華 提交于 2020-12-28 06:54:06
问题 Now I have a class User, I get a request data of an array from the jsp or html . list this Integer[] arr=[5,6,9,10,62,52,21] and then I use two methods to finish bulking deleting action. @Transactional @Override public void deleteUser(Integer id) { oneRepository.delete(id); } @Transactional @Override public void deleteSomeUser(Integer[] ids) { for (Integer id : ids) { deleteUser(id); } } I want to know that if it's a more efficient method to finish this action. you can see my logs: it seems

Spring JPA :: No converter found capable of converting from type

心不动则不痛 提交于 2020-12-28 06:43:26
问题 I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other dto as I do not want all the columns. getting below error No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [webapi.dto.StatsDTO]", Below is my repository interface public interface UserRepository extends

Spring JPA :: No converter found capable of converting from type

余生长醉 提交于 2020-12-28 06:43:25
问题 I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other dto as I do not want all the columns. getting below error No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [webapi.dto.StatsDTO]", Below is my repository interface public interface UserRepository extends

Spring JPA :: No converter found capable of converting from type

心不动则不痛 提交于 2020-12-28 06:42:44
问题 I am using spring with JPA and trying to execute query using @query with SQL query.and trying to map the result to an object. I have different entity class and mapping to other dto as I do not want all the columns. getting below error No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [webapi.dto.StatsDTO]", Below is my repository interface public interface UserRepository extends