spring-data-commons

How can I use a custom ID conversion with DomainClassConverter?

风格不统一 提交于 2019-12-25 11:47:32
问题 I have a SQL database where primary keys are UUIDs, but the canonical string representation of a UUID is very long, and I would like to use a shortened version (Base58) in my URLs. Spring Data's DomainClassConverter will convert MVC request parameters or path variables into domain objects, but I want to be able to modify the resolved ID before it's passed to the repository. The default SpringDataWebConfiguration creates a DomainClassConverter using a FormattingConversionService supplied by

Generate links with additional query parameters using PagedResourcesAssembler

Deadly 提交于 2019-12-22 06:56:02
问题 I'm using spring-data-common's PagedResourcesAssembler in my REST controller, and I was happy to see it even generates next/previous links in the response. However, in those cases where I have additional query parameters (besides page, size, sort), these are not included in the generated links. Can I somehow configure the assembler to include the parameters in the links? Many thanks, Daniel 回答1: You need to build base link by yourself and pass it to "toResource" method of

Can it register an domain event in the constructor of aggregate root, when using Spring Data Common

大憨熊 提交于 2019-12-13 03:15:46
问题 The aggregate will be created by some application service , not by another aggregate. Like this SomeAggregate aggregate = new SomeAggregate(); repo.save(aggregate); The expectation is that the aggregate is saved and one SomeAggregateCreated event is published when the application service is over. I have tested it, it is not always effective, sometimes the event is not registered immediately after the constructor is executed. This is the teacher class: public class Teacher extends

Failed to query by spring-data-jpa query methods with suffix IN due to the cachedCriteriaQuery is not correct on openjpa 2.4.1

◇◆丶佛笑我妖孽 提交于 2019-12-13 02:06:21
问题 Update: After I digged into the source code of spring-data-jpa repository query methods, I found the root cause is the createQuery method of PartTreeJpaQuery as below. This method will be called by the invoke method of the QueryExecutorMethodInterceptor of the RepositoryFactorySupport when you call the spring-data-jpa repository query methods interface. public Query createQuery(Object[] values) { CriteriaQuery<?> criteriaQuery = cachedCriteriaQuery; List<ParameterMetadata<?>> expressions =

No suitable constructor found for type GeoJsonPoint

雨燕双飞 提交于 2019-12-11 13:11:35
问题 Having a lot of trouble figuring out what I'm doing wrong. Sadly I had it working at one point, but can't determine what I changed that broke it. From what I understand this should be fully supported now. Object in question: @Document public class Place { public final static String URI = "/place"; @Id private String id; private String name; private String caption; private GeoJsonPoint location; public Place() {} public Place(GeoJsonPoint geoJsonPoint) { this.location = geoJsonPoint; } //

The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?

纵饮孤独 提交于 2019-12-07 06:20:06
问题 I had been using the WebMvcConfigurerAdapter for a while. Since i could not get all the registered interceptors with the method getInterceptors(), i have switched to WebMvcConfigurationSupport, which has lot of default registered Spring Beans like ContentNegotiationManager, ExceptionHandlerExceptionResolver usw. Now i have realised that, the very handy DomainClassConverter (which converts the domain class ids to domain class objects by using a CrudRepository) is not registered by default,

The annotation @EnableSpringDataWebSupport does not work with WebMvcConfigurationSupport?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 10:30:44
I had been using the WebMvcConfigurerAdapter for a while. Since i could not get all the registered interceptors with the method getInterceptors(), i have switched to WebMvcConfigurationSupport, which has lot of default registered Spring Beans like ContentNegotiationManager, ExceptionHandlerExceptionResolver usw. Now i have realised that, the very handy DomainClassConverter (which converts the domain class ids to domain class objects by using a CrudRepository) is not registered by default, although i use the annotation @EnableSpringDataWebSupport on my WebConfig class. When i define this bean

PageRequest constructors have been deprecated

一世执手 提交于 2019-11-30 05:35:49
I'm working the Spring Data Commons v2+ snapshot, and I see that the constructors for a PageRequest have been deprecated. This appears to have occurred between M1 & M2 . Unfortunately, this is the only [real] implementation of the Pageable interface. I'm wondering where the effort is heading, and what a better alternative would be for current development. Veluria It's just the constructors which have been deprecated. Instead of new PageRequest(firstResult, maxResults, new Sort(...)) you can now use PageRequest.of(firstResult, maxResults, Sort.by(...)) and that's it. Feroz Mujawar You can use

PageRequest constructors have been deprecated

一曲冷凌霜 提交于 2019-11-27 13:24:33
问题 I'm working the Spring Data Commons v2+ snapshot, and I see that the constructors for a PageRequest have been deprecated. This appears to have occurred between M1 & M2. Unfortunately, this is the only [real] implementation of the Pageable interface. I'm wondering where the effort is heading, and what a better alternative would be for current development. 回答1: It's just the constructors which have been deprecated. Instead of new PageRequest(firstResult, maxResults, new Sort(...)) you can now