spring-data

Log values of query parameters in Spring Data R2DBC?

廉价感情. 提交于 2021-02-20 16:15:25
问题 In Spring Data R2DBC I can log SQL queries by using logging.level.org.springframework.data.r2dbc=DEBUG in the application.properties . However, this doesn't log the actual values that are bound as query parameters. How can I log the actual values of query parameters in Spring Data R2DBC? 回答1: This worked for me : logging: level: io.r2dbc.postgresql.QUERY: DEBUG # for queries io.r2dbc.postgresql.PARAM: DEBUG # for parameters I found it here 回答2: If you happen to use MySQL, you can get a low

Add optional query parameter using spring data mongodb repository

試著忘記壹切 提交于 2021-02-19 06:07:20
问题 I want to add optional query parameters using spring data mongodb. Controller code: @RestController private final ActionService actionService; @RequestMapping(value = "/action/{id}", method = RequestMethod.GET) public ResponseEntity<List<Action>> getActionList(@PathVariable("id") long id, @RequestParam(value = "actionType", required = false) ActionType actionType, @RequestParam(value = " ", required = false) String[] params) { List<Action> actionList = actionService.getAction(id, actionType,

How spring data clean persited entities in transactional method?

房东的猫 提交于 2021-02-19 03:48:31
问题 I need to receive and save huge amount of data using spring data over hibernate. Our server allocated not enough RAM for persisting all entities at the same time. We will definitely get OutOfMemory error. So we need to save data by batches it's obvious. Also we need to use @Transactional to be sure that all data persisted or non was persisted in case of even single error. So, the question: does spring data during @Transactional method keep storing entities in RAM or entities which were

Spring config xml isn't valid after adding spring-data-jpa schema references

て烟熏妆下的殇ゞ 提交于 2021-02-19 03:34:09
问题 I have the following Exception while starting the spring context: java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/; lineNumber: 1; columnNumber: 55; White spaces are required between publicId and systemId. Before I added the spring-data-jpa to the spring config.xml everything worked fine.

How can I coax Spring Data to show me mongo's query plan (a.k.a cursor.explain())

ぃ、小莉子 提交于 2021-02-18 15:34:33
问题 I am writing an API with Spring/Mongo/Jersey to do CRUD on a POJO that has a generic map of properties like this: public class Thing { private String id; @Indexed private Map<String,String> properties; ... This is working great to return items. My resource code looks like this: BasicDBObject query = new BasicDBObject("properties.name", "vlad the impaler"); return Response.ok(myService.queryThings(query)).build(); And my abstract DAO looks like this: public List<T> find(Query query) { return

Spring data jpa - modifying query before execution

北战南征 提交于 2021-02-18 07:37:04
问题 I'm working on a project that keeps some access control information in the database. We're using that access control information to filter what the user can see. The filter that we're using is based on roles that the user has. We would like to use the Repository abstraction provided by Spring Data, but we would like to be able to adjust the generated queries before they are executed. Is there a way to attach a listener or an interceptor that will be called before a query is executed? That way

Compare LocalDate with LocalDateTime in HQL/JPQL

…衆ロ難τιáo~ 提交于 2021-02-11 14:53:24
问题 Is it possible to compare LocalDate with LocalDateTime in HQL/JPQL? This is my query of repository method in spring data which should return amount of orders per required dates. The field deliveryDateTime in Order entity has type LocalDateTime . I want to ignore time part and compare only date part. @Query("SELECT new OrderCountPerDate(DATE(o.deliveryDateTime), COUNT(o.id)) FROM Order o WHERE DATE(o.deliveryDateTime) IN :dates GROUP BY DATE(o.deliveryDateTime) ") List<LocalDate>

How to test spring batch job within @Transactional SpringBootTest test case?

早过忘川 提交于 2021-02-11 14:46:25
问题 I just can't seem to win today... Is there a way to read from a OneToMany relationship in a Spock SpringBootTest integration test, without annotating the test as @Transactional or adding the unrealistic spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true ? OR, is there a way to launch a Spring-Batch Job from within a @Transactional test case? Let me elaborate... I'm trying to get a simple Spring Boot Integration test working for my Spring Batch reporting process, which reads from

Spring data rest application not getting data from database after implementing redis caching

橙三吉。 提交于 2021-02-11 14:44:08
问题 I am working on implementing Redis caching for my spring data rest (hal) api. Requirement: cache all data to redis after first call to database and perform operations on redis. like Add record should first happen in cache and then inserted in database in a transaction. I implemented caching for one of the JpaRepository, but when I do implicit findAll by calling the /states endpoint, I get no records, even when I have 10k records in database. Please help guys!! Below is my config:

PageRequest and OrderBy method name Issue

被刻印的时光 ゝ 提交于 2021-02-11 14:14:06
问题 in our Spring application we have a table that contains a lot of "Payment" record. Now we need a query that pages the results sorted from the one with the largest total to the smallest, we are facing an error because sometimes the same record is contained in two successive pages. We are creating a PageRequest passed to the repository. Here our implementation: Repository: public interface StagingPaymentEntityRepository extends JpaRepository<StagingPaymentEntity, Long> { Page