spring-data

How to do source filtering in ElasticSearch in spring boot project?

徘徊边缘 提交于 2020-07-23 06:41:07
问题 how to make Elastic search query return only particular fields in spring boot project using spring-data-elasticsearch? we are using most recent versions of spring boot and elastic search. Which template to use elasticsearchtemplate or elasticsearchresttemplate and how both of them are different from java high level rest client? 回答1: If you are using the ElasticsearchOperations interface (which ElasticsearchTemplate and ElasticsearchRestTemplate implement), the Query interface that is used to

How to do source filtering in ElasticSearch in spring boot project?

孤者浪人 提交于 2020-07-23 06:40:20
问题 how to make Elastic search query return only particular fields in spring boot project using spring-data-elasticsearch? we are using most recent versions of spring boot and elastic search. Which template to use elasticsearchtemplate or elasticsearchresttemplate and how both of them are different from java high level rest client? 回答1: If you are using the ElasticsearchOperations interface (which ElasticsearchTemplate and ElasticsearchRestTemplate implement), the Query interface that is used to

Modify and return ModelAttribute object if validation fails

别等时光非礼了梦想. 提交于 2020-07-22 21:35:41
问题 I have simple entity ... @Entity public class WatchedDirectory { @Column(nullable=false) @NotBlank(message="Filesystem path CANNOT be empty") String filesystemPath; } ... and GET endpoint for creating one ... @GetMapping("/add") public String add(@ModelAttribute WatchedDirectory watchedDirectory) { return "mng-dir-add"; } ... that shows form made in Thymeleaf, with error validation and all. Once you hit sumbmit button data goes into POST endpoint ... @PostMapping("/add") public String

Modify and return ModelAttribute object if validation fails

早过忘川 提交于 2020-07-22 21:35:12
问题 I have simple entity ... @Entity public class WatchedDirectory { @Column(nullable=false) @NotBlank(message="Filesystem path CANNOT be empty") String filesystemPath; } ... and GET endpoint for creating one ... @GetMapping("/add") public String add(@ModelAttribute WatchedDirectory watchedDirectory) { return "mng-dir-add"; } ... that shows form made in Thymeleaf, with error validation and all. Once you hit sumbmit button data goes into POST endpoint ... @PostMapping("/add") public String

Spring Data Rest repositories occasionally not exported

微笑、不失礼 提交于 2020-07-19 07:03:02
问题 I'm having a weird issue in my Spring Boot application ( 2.2.6.RELEASE ) using Spring Data Rest ( 3.2.6.RELEASE ). From time to time my repositories are not exposed via rest. This is happening with the exact same version (same jar) of my application using the exact same configuration. There are 4 @RepositoryRestResource 's and when it's working, the root resource exposes this: { "_links": { "entity-a": { "href": "http://localhost:8080/api/entity-a{?projection}", "templated": true }, "entity-b

Spring Data Rest repositories occasionally not exported

独自空忆成欢 提交于 2020-07-19 07:01:06
问题 I'm having a weird issue in my Spring Boot application ( 2.2.6.RELEASE ) using Spring Data Rest ( 3.2.6.RELEASE ). From time to time my repositories are not exposed via rest. This is happening with the exact same version (same jar) of my application using the exact same configuration. There are 4 @RepositoryRestResource 's and when it's working, the root resource exposes this: { "_links": { "entity-a": { "href": "http://localhost:8080/api/entity-a{?projection}", "templated": true }, "entity-b

Set the fetch size with Spring Data

点点圈 提交于 2020-07-17 06:45:46
问题 For large result sets, it’s important to increase the fetch size. There have been numerous discussions on how to set the fetch size for Spring’s JdbcTemplate . However, we usually use Spring Data for database access. How can I set the fetch size for a Spring Data query, assuming we use JPA with Hibernate as provider? 回答1: It depends on what you want to set. If you want it globally simply add it as a property to your persistence.xml (or what your way of configuration the EntityManagerFactory

Set the fetch size with Spring Data

北城余情 提交于 2020-07-17 06:45:10
问题 For large result sets, it’s important to increase the fetch size. There have been numerous discussions on how to set the fetch size for Spring’s JdbcTemplate . However, we usually use Spring Data for database access. How can I set the fetch size for a Spring Data query, assuming we use JPA with Hibernate as provider? 回答1: It depends on what you want to set. If you want it globally simply add it as a property to your persistence.xml (or what your way of configuration the EntityManagerFactory

Is it problematic that Spring Data REST exposes entities via REST resources without using DTOs?

若如初见. 提交于 2020-07-16 12:59:51
问题 In my limited experience, I've been told repeatedly that you should not pass around entities to the front end or via rest, but instead to use a DTO. Doesn't Spring Data Rest do exactly this? I've looked briefly into projections, but those seem to just limit the data that is being returned, and still expecting an entity as a parameter to a post method to save to the database. Am I missing something here, or am I (and my coworkers) incorrect in that you should never pass around and entity? 回答1:

Get all non-full fields in ElasticsearchRepository's findAll method in Spring Data Elasticsearch

亡梦爱人 提交于 2020-07-14 12:20:23
问题 We are using we're using spring-data-elasticsearch 3.2.6.RELEASE and here is our repository : @Repository public interface IRepository extends ElasticsearchRepository<User, Integer> { List<User> findAll(); } and here is the sample response: [{ "idDl": null, "clientName": null, "Address": null }, { "idDl": 19810008, "clientName": "ABC", "Address": "NYC" }] And we have our own custom implementation to return all values excluding certain fields, as follows: It is exposed as separate REST point.