spring-data

Spring querydsl predicate: relationship support

我与影子孤独终老i 提交于 2020-01-01 18:54:14
问题 I have a Client entity with an OneToOne relation with Contact. If I want to get the client name, I need to write: client.getContact().getLastName() I use querydsl lib to filters client list in my spring boot app /api/clients?contact.lastName=Doe My controller signature: public ResponseEntity<ResponseListDTO> getClients ( @QuerydslPredicate(root = Client.class) Predicate predicateClient, Pageable pageable) It works well: predicate is well created and filters works. But now I need to filter on

Enabling Logging for JpaTransactionManager

大城市里の小女人 提交于 2020-01-01 17:00:54
问题 I am using JpaTransactionManager with hibernate 3 inside spring 3.5 container. I am not able to enable logging for JPA. I wish to see the logs for transaction management for debugging some of my services. I am using log4j. Here is what I have in my log4j.properties # For JPA log4j.logger.org.springframework.orm.jpa=DEBUG log4j.logger.org.springframework.orm.jpa.JpaTransactionManager=DEBUG log4j.logger.org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter=DEBUG log4j.logger.org

How to compare 2 fields in Spring Data MongoDB using query object

别说谁变了你拦得住时间么 提交于 2020-01-01 16:50:14
问题 What seems almost natural in simple SQL is impossible in mongodb . Given a simple document: { "total_units" : 100, "purchased_unit" : 60 } I would like to query the collection, using spring data Criteria class, where "total_units > purchased_units" . To my understanding it should be as trivial as any other condition. Found nothing to support this on Spring api. 回答1: I don't think Spring Data API supports this yet but you may need to wrap the $where query in your Java native DbObject. Note,

Spring Data JPA: Sorting and paging with joined tables

孤人 提交于 2020-01-01 13:38:10
问题 I have a scenario where I want to filter, sort and page over a result where 3 tables take part. At the moment I use Spring Data JPA's Specification feature to do it on a single entity: repository.findAll(specification, pageRequest) . This works great, but now I have another scenario where the sort / filter attributes are spread over 3 tables which are connected by one-to-many relations. Here is my scenario: @Entity public class CustomerEntity ... { ... @Column(nullable = false) public String

Spring Data JPA: Sorting and paging with joined tables

无人久伴 提交于 2020-01-01 13:35:50
问题 I have a scenario where I want to filter, sort and page over a result where 3 tables take part. At the moment I use Spring Data JPA's Specification feature to do it on a single entity: repository.findAll(specification, pageRequest) . This works great, but now I have another scenario where the sort / filter attributes are spread over 3 tables which are connected by one-to-many relations. Here is my scenario: @Entity public class CustomerEntity ... { ... @Column(nullable = false) public String

How can I customize the AuditingHandler injected by Spring-Data when using Auditing?

不想你离开。 提交于 2020-01-01 04:51:09
问题 I'm using Spring Data 1.5 and Auditing. Part of the AuditingEntityListener has a setAuditingHandler method. How can I customize the AuditingHandler and instruct Spring-Data to inject my custom handler instead of the default org.springframework.data.auditing.AuditingHandler ? I've tried instantiating my own AuditingEntityListener in which I inject my own Handler, but that is not doing the job. The default handler is still being injected. I've tried both via XML configuration and JavaConfig to

Spring Data JPA and spring-security: filter on database level (especially for paging)

寵の児 提交于 2020-01-01 04:30:09
问题 I'm trying to add method level security to my open source project using annotations and spring-security. The problem I'm now facing are findAll methods especially the ones for Paging (eg. returning a page). Using @PostFilter works on Lists (but I personally believe its not a good idea to filter in application and not database) but completely fails on paging queries. This is problematic because I have an Entity containing List<Compound> . There are different implementations of compound and a

Spring Boot : Error creating bean with name 'jpaMappingContext': java.lang.NullPointerException

拟墨画扇 提交于 2020-01-01 04:11:08
问题 My combination of is Spring Boot + Spring Data Jpa + Multiple Databases. I am getting following NullPointer exception when starting the application. Feels like SPring Data with Boot is not able to generate JPA Metadata. I did not get any resource related to this error. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.NullPointerException at org.springframework

spring-data-elasticsearch searching over multiple indices

╄→尐↘猪︶ㄣ 提交于 2020-01-01 03:50:06
问题 i have a searchfield on my page and this searchfield should search over more than one indice. I can search for one indice without a problem, like described in the documentation of spring-data-elasticsearch. But if i search, as example for "Foo", i want to have the following list as result ordered by relevance: { title: "Foo" } -> Entity: Sample { name: "FooTest" } -> Entity: Test { title: "FooSample2" } -> Entity: Sample // ...and so on // The entities are not part of the same parent. So,

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of org.springframework.data.domain.Sort out of START_ARRAY token

痞子三分冷 提交于 2020-01-01 03:47:05
问题 My objectMapper is fetching the value of type Page<User> as follows: userList = objectMapper.readValue(RestAdapter.get(url), new TypeReference<PageImplBean<User>>(){}); The PageImplBean extends PageImpl class as follows: public class PageImplBean<T> extends PageImpl<T> { private static final long serialVersionUID = 1L; private int number; private int size; private int totalPages; private int numberOfElements; private long totalElements; private boolean previousPage; private boolean first;