spring-data-rest

Spring Boot LocalDate field serialization and deserialization

旧城冷巷雨未停 提交于 2019-12-01 07:39:12
On spring boot 1.2.3.RELEASE with fasterxml what is the correct way of serializing and de-serializing a LocalDate field to iso date formatted string? I've tried: spring.jackson.serialization.write-dates-as-timestamps:false in application.properties file, including jackson-datatype-jsr310 in project and then using @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") annotation and @DateTimeFormat(iso=ISO.DATE) annotation, adding Jsr310DateTimeFormatAnnotationFormatterFactory as formatter with: @Override public void addFormatters(FormatterRegistry registry) { registry

Spring Data Rest : How to expose a json schema from a repository (2.0.0.M1)

限于喜欢 提交于 2019-12-01 06:33:58
I saw in the source code that Spring DATA Rest can expose a Json Schema for a repository with this URL : /{repository}/schema. Is there anybody who know how to configure this ? There is the RepositorySchemaController (org.springframework.data.rest.webmvc) but i have not found how to use it. version : 2.0.0.M1 Make sure you set the right headers... Request - /{repository}/schema Header - Accept: application/json+schema Also if you haven't looked into 2.0 snapshots, there are lot more features and changes coming up EDIT: Jan 27 2014 Correction: Accept should be " application/schema+json "

How to reference an entity with inheritance in Spring Data REST when POSTing new entity?

為{幸葍}努か 提交于 2019-12-01 06:20:57
问题 I have entities with joined inheritance: Supporter @Entity @Inheritance(strategy=InheritanceType.JOINED) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "supporterType") @JsonSubTypes({ @JsonSubTypes.Type(value = PersonSupporterEntity.class, name = "PERSON"), @JsonSubTypes.Type(value = CompanySupporterEntity.class, name = "COMPANY") }) @DiscriminatorColumn(name="supporter_type") @Table(name = "supporter") public class SupporterEntity extends

Password encoding with Spring Data REST

吃可爱长大的小学妹 提交于 2019-12-01 05:09:23
问题 How should I encode automatically the subbmitted plain password field of my entity with Spring Data REST? I'm using BCrypt encoder and I want to automatically encode the request's password field, when the client send it via POST, PUT and PATCH. @Entity public class User { @NotNull private String username; @NotNull private String passwordHash; ... getters/setters/etc ... } First I tried to solve with @HandleBeforeCreate and @HandleBeforeSave event listeners but the User in it's argument is

Spring Data Rest : How to expose a json schema from a repository (2.0.0.M1)

流过昼夜 提交于 2019-12-01 03:39:17
问题 I saw in the source code that Spring DATA Rest can expose a Json Schema for a repository with this URL : /{repository}/schema. Is there anybody who know how to configure this ? There is the RepositorySchemaController (org.springframework.data.rest.webmvc) but i have not found how to use it. version : 2.0.0.M1 回答1: Make sure you set the right headers... Request - /{repository}/schema Header - Accept: application/json+schema Also if you haven't looked into 2.0 snapshots, there are lot more

spring-data-rest integration test fails with simple json request

做~自己de王妃 提交于 2019-12-01 02:43:42
My spring-data-rest integration test fails for a simple json request. Consider the below jpa models Order.java public class Order { @Id @GeneratedValue// private Long id; @ManyToOne(fetch = FetchType.LAZY)// private Person creator; private String type; public Order(Person creator) { this.creator = creator; } // getters and setters } Person.java ic class Person { @Id @GeneratedValue private Long id; @Description("A person's first name") // private String firstName; @Description("A person's last name") // private String lastName; @Description("A person's siblings") // @ManyToMany // private List

Spring Data Rest Add custom endpoint to specific reposiotry

霸气de小男生 提交于 2019-11-30 23:03:25
I would like to add a custom search endpoint to my existing user repository. My user Repository looks like this: @RepositoryRestResource(collectionResourceRel="users", path="users") public interface UserRepository extends PagingAndSortingRepository<User, Long>{ User findByUsername(String username); } The custom controller: @BasePathAwareController @RequestMapping("users/search") public class CustomController implements ResourceProcessor<RepositorySearchesResource>, ResourceAssembler<User, Resource<User>> { @Autowired UserRepository userReposiotry; @Autowired private EntityLinks entityLinks;

Spring Data Rest - sort by nested property

倖福魔咒の 提交于 2019-11-30 22:53:30
问题 I have a database service using Spring Boot 1.5.1 and Spring Data Rest. I am storing my entities in a MySQL database, and accessing them over REST using Spring's PagingAndSortingRepository. I found this which states that sorting by nested parameters is supported, but I cannot find a way to sort by nested fields. I have these classes: @Entity(name = "Person") @Table(name = "PERSON") public class Person { @ManyToOne protected Address address; @ManyToOne(targetEntity = Name.class, cascade = {

spring-data-rest integration test fails with simple json request

我只是一个虾纸丫 提交于 2019-11-30 22:28:09
问题 My spring-data-rest integration test fails for a simple json request. Consider the below jpa models Order.java public class Order { @Id @GeneratedValue// private Long id; @ManyToOne(fetch = FetchType.LAZY)// private Person creator; private String type; public Order(Person creator) { this.creator = creator; } // getters and setters } Person.java ic class Person { @Id @GeneratedValue private Long id; @Description("A person's first name") // private String firstName; @Description("A person's

How to add elements in a many-to-many relationship via Spring's @RepositoryRestResource REST API?

瘦欲@ 提交于 2019-11-30 22:26:07
I'm having trouble figuring out exactly how to use the @RepositoryRestResource interface to create many-to-many relationships between two fairly simple entities. For example, I have a simple parent-child entity relationship like this: @Entity public class ParentEntity { @Id @GeneratedValue private Long id; @ManyToMany private List<ChildEntity> children; } @Entity public class ChildEntity { @Id @GeneratedValue private Long id; @ManyToMany(mappedBy="children") private List<ParentEntity> parents; } My repositories are using the vanilla Spring @RepositoryRestResource HATEOS API: