spring-data-rest

How do I avoid n+1 queries with Spring Data Rest?

老子叫甜甜 提交于 2019-11-28 15:23:45
问题 Question. How do I avoid n+1 queries with Spring Data REST? Background. When querying Spring Data REST for a list of resources, each of the resulting top-level resources has links to the associated resources, as opposed to having the associated resources embedded directly in the top-level resources. For example, if I query for a list of data centers, the associated regions appear as links, like this: { "links" : [ { "rel" : "self", "href" : "http://localhost:2112/api/datacenters/1" }, { "rel"

Spring Data rest how to perform CRUD on @manytomany relation ,composite table with extra column

天大地大妈咪最大 提交于 2019-11-28 12:59:17
I am unable to perform CRUD via json POST from restful client Postman on Composite table having extra column .I am using Spring boot ,spring data rest and spring JPA. I have 3 tables in data base -user -competency -user_competency (join/composite table with extra column) Here are my classes User @Entity @Table(name = "\"user\"", schema = "public") @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "userId") public class User implements java.io.Serializable { private Long userId; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user

Creating Resource with references using spring data rest

Deadly 提交于 2019-11-28 11:59:32
问题 I am using spring data rest, I have following entities exposed via spring data rest DonationRequest @Data @Entity @Table(name="donation_request",schema="public") public class DonationRequest { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="donation_request_id") Integer donationRequestId; @Column(name="expiry_datetime") Date expiryDatetime; @Column(name="blood_group") String bloodGroup; @Column(name="no_of_bottles") String noOfBottles; @OneToOne @JoinColumn(name=

Spring Rest: Cannot insert rows that have @ManyToOne column

半世苍凉 提交于 2019-11-28 11:42:36
问题 I am following a spring getting started tutorial in https://spring.io/guides/gs/accessing-data-rest/ I added another entity books that has @ManyToOne relation to Person entity. Person entity has a new property called bikes and has a @OneToMany relation with Bike entity. Only thing that is different from the getting started project is the new attribute with its getter and setter: package hello; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue;

spring data rest with composite primary key

房东的猫 提交于 2019-11-28 11:32:23
I use spring data rest for crud. But when the entity has composite primary keys, I dont know how to to get an entity by giving the primary key. River class: @Entity public class River { private RiverPK id; private Double length; private Timestamp date; private String comment; @Basic @Column(name = "length") public Double getLength() { return length; } public void setLength(Double length) { this.length = length; } @Basic @Column(name = "date") public Timestamp getDate() { return date; } public void setDate(Timestamp date) { this.date = date; } @Basic @Column(name = "comment") public String

Spring REST LocalDate UTC differs of one day

做~自己de王妃 提交于 2019-11-28 10:30:04
问题 I'm using Spring Boot 1.5.4, Hibernate 5.2.10, Spring Data REST, HATEOAS, JDK8 with LocalDate and LocalDateTime. My computer is on CEST timezone but I want the application works in UTC, so I set in application.properties: spring.datasource.url=jdbc:mysql://localhost:3306/database?useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=true spring.jpa.hibernate.jdbc.time_zone = UTC According to this article I don't want to change the timezone of my JVM because seems not to be a best practice.

Different JSON output when using custom json serializer in Spring Data Rest

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:31:28
After adding a custom Jackson serializer based on the official documenation I've observed a slightly different json output format. This example is based on a fork of spring-restbucks . Extend org.springsource.restbucks.WebConfiguration from RepositoryRestMvcConfiguration and override configureJacksonObjectMapper : @Override protected void configureJacksonObjectMapper(ObjectMapper objectMapper) { final SimpleSerializers serializers = new SimpleSerializers(); serializers.addSerializer(Order.class, new OrderSerializer()); objectMapper.registerModule(new SimpleModule("CustomSerializerModule"){

Handle spring-data-rest application events within the transaction

依然范特西╮ 提交于 2019-11-28 08:26:22
I need to publish notification events to external systems over JMS, when data is updated. Id like this to be done within the same transaction as the objects are committed to the database to ensure integrity. The ApplicationLifecycle events that spring-data-rest emits seemed like the logical place to implement this logic. @org.springframework.transaction.annotation.Transactional public class TestEventListener extends AbstractRepositoryEventListener<Object> { private static final Logger LOG = LoggerFactory.getLogger(TestEventListener.class); @Override protected void onBeforeCreate(Object entity)

Spring Data Rest Without HATEOAS

主宰稳场 提交于 2019-11-28 08:24:48
I really like all the boilerplate code Spring Data Rest writes for you, but I'd rather have just a 'regular?' REST server without all the HATEOAS stuff. The main reason is that I use Dojo Toolkit on the client side, and all of its widgets and stores are set up such that the json returned is just a straight array of items, without all the links and things like that. Does anyone know how to configure this with java config so that I get all the mvc code written for me, but without all the HATEOAS stuff? After reading Oliver's comment (which I agree with) and you still want to remove HATEOAS from

How to expose @EmbeddedId converters in Spring Data REST

好久不见. 提交于 2019-11-28 07:48:57
There are some Entities with composite Primary Keys and these entities when exposed are having incorrect Links having full qualified name of classes in URL inside _links Also clicking on links gives such errors - org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type com.core.connection.domains.UserFriendshipId I have XML configured Spring Repository with jpa:repositories enabled and Respository extending from JpaRepository Can I make Repository implement org.springframework.core.convert.converter.Converter to