spring-data-rest

spring-data-rest: query giving “Unparseable date” when query param matches @DateTimeFormat

我的未来我决定 提交于 2019-12-11 05:04:10
问题 I am developing a spring-boot REST server using spring-boot-starter-data-jpa-1.5.2.RELEASE. I have the following POJO class hierarchy. First the base class Entity: @javax.persistence.Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class Entity implements Serializable { @Id @Column(name = "id", nullable = false, length = 48) public String id = UNINITIALIZED_ID; /** * The timestamp for when this entity was last updated. */ @Column(columnDefinition = "timestamp

Spring Boot and Spring Data Rest

狂风中的少年 提交于 2019-12-11 04:10:24
问题 I want to use Spring Data Rest in my Spring Boot project but I am running into difficulty. I am using Spring boot version 2.0.0.M2. I also tried version 1.5.4.RELEASE but got the same error I am using the following imports in my pom <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-jdbc</artifactId> </exclusion> </exclusions> </dependency> <dependency>

Exposing link on collection entity using spring hateoas

元气小坏坏 提交于 2019-12-11 04:03:42
问题 I have pretty the same question as it has been asked here (Exposing link on collection entity in spring data REST). But nothing from that topic helps me to add custom link to collection call. @Component public class EventListResourceProcessor implements ResourceProcessor<Resources<Event>> { @Autowired private RepositoryEntityLinks entityLinks; @Override public Resources<Event> process(Resources<Event> events) { events.add(entityLinks.linkToCollectionResource(Event.class).withRel("events"));

why is the Object Mapper date fromat not used by message converters for date transform?

ぃ、小莉子 提交于 2019-12-11 04:02:42
问题 I am facing an issue with customised date formatting for JSON, where it of-course works in tests but fails on the deployed application. I want to use date pattern as dd-MM-yyyy pretty much standard and how it is expected here in India. There is a date formatter configured as well, and injected in the configuration like so @Configuration public class RepositoryWebConfiguration extends RepositoryRestMvcConfiguration { private static final Logger LOGGER = LoggerFactory.getLogger

Repository method only works returning the whole entity instead of some properties

笑着哭i 提交于 2019-12-11 01:06:58
问题 I cannot return specific properties of an entity class from a repository method. Exception stacktrace Resolving exception from handler [public org.springframework.http.ResponseEntity<java.lang.Object> org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch ( org.springframework.data.rest.webmvc.RootResourceInformation, org.springframework.util.MultiValueMap<java.lang.String, java.lang.Object>, java.lang.String, org.springframework.data.rest.webmvc.support

Why is @PreAuthorize with hasPermission (in custom PermissionEvaluator) triggered in one Repository but not in the other?

江枫思渺然 提交于 2019-12-10 23:59:19
问题 For some weird reason my @PreAuthorize annotation with a hasPermission expression is triggered from ONE of my repositories but not in another that seems almost identical. Just to get this out of the way first, I have enabled GlobalMethodSecurity with prePostEnabled = true . I have also written a custom PermissionEvaluator. import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.access

Spring data rest @ManyToOne field is not coming in json

落爺英雄遲暮 提交于 2019-12-10 22:32:39
问题 I am developing a web project using Spring Boot, Spring Data JPA and Spring Data Rest technologies. I am able to setup everything successfully and able to get JSON of a simple POJOs. I have customized two classes to have OneToMany and ManyToOne relationship like this:- @Entity @Table(name="t_profile") public class Profile { @Id @column(name="profile_id") @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String name; @JoinColumn(name = "cat_id", referencedColumnName =

How to create Spring Data Rest entities response format manually [duplicate]

删除回忆录丶 提交于 2019-12-10 22:12:23
问题 This question already has answers here : Calling spring data rest repository method doesn't return links (2 answers) Closed 3 years ago . I'm using Spring Data Rest to create a RESTful api. I want to handle an exception returning an entity representation like the ones generated by the Spring Data Rest repositories (with HATEOAS links). The method from where I need to return the entity representation is the following: @ExceptionHandler(value = {ExistentUGVException.class}) @ResponseBody

Defining custom methods with path “/{resourcename}/search/” using spring-data-rest

a 夏天 提交于 2019-12-10 21:05:59
问题 I am confused. I could not find out, how to define together custom "search" methods with methods that were loaded with help of spring-data-rest. Could you answer me, does the framework has this possibility "out-of-box"? And if has, could you tell me, where can i find it? For a deeper understanding my situation i describe my issue: class UserService { public String getListOfWaitingUsers() { return userRepository.findAll(UserSpecification.isWaiting()); } } public interface UserRepository

How to add “book” to /shelves/1/books

空扰寡人 提交于 2019-12-10 20:53:52
问题 I can't figure out how to do something that should be incredibly simple. I have two entities: shelf and book. A shelf can have one or more books. Each of these entities has a corresponding JpaRepository exposed as a rest repository using Spring Data Rest. When I run the application, all of the query endpoints work perfectly, but I can't figure out how I can add a book to a shelf. First I add a shelf by POSTing { "name":"westerns"} to /shelves (works fine). Method 1: I try to add a book by