spring-data

Specification/Predicate to Search Nested Objects

六月ゝ 毕业季﹏ 提交于 2020-02-01 08:50:43
问题 I'm using Spring Boot with Spring JPA and Specification Executor. I have my Specification/Predicate combo successfully searching the simple attributes within my class. However, I am having difficulties searching the objects within. Do they need a separate Specification? I have a class that has 2 Many To One mapping classes within and would like to search those fields from within the same class. Predicate Implementation public Specification<User> getSpecification(SpecificationField field,

Specification/Predicate to Search Nested Objects

扶醉桌前 提交于 2020-02-01 08:50:28
问题 I'm using Spring Boot with Spring JPA and Specification Executor. I have my Specification/Predicate combo successfully searching the simple attributes within my class. However, I am having difficulties searching the objects within. Do they need a separate Specification? I have a class that has 2 Many To One mapping classes within and would like to search those fields from within the same class. Predicate Implementation public Specification<User> getSpecification(SpecificationField field,

How to configure two instance mongodb use spring boot and spring data

一世执手 提交于 2020-02-01 07:29:44
问题 The First instance is the embedded MongoDb, the second instance is the live MongoDb. How do it configure use spring data and spring boot. How to switch easily these instances by properties file?? UPDATE By default application should start build-in database and store data into APPDIR/db directory It should be possible to let application know that external database will be used by configuring mongo.url property. In this case no need to start internal database. Instead of that external

Spring Data - Overriding default methods for some repositories

有些话、适合烂在心里 提交于 2020-01-31 05:25:06
问题 I am just staring with spring-data and spring-data-rest and I really want to take advantage of what these tools have to offer. For the most case the base functionality is perfect for my use case however there are some cases where I need to customize the underlying functionality quite a bit, and selectively assign some repositories to inherit the customized functionality I am after. To explain the problem a bit better, in spring-data there are 2 possible interfaces which you can inherit

Spring Data- how to tell spring what entities to retrieve

杀马特。学长 韩版系。学妹 提交于 2020-01-30 11:22:08
问题 If i have several entites, lets say : @Entity class Book{ String name; Author author; } @Entity class Author{ String name; City hometown; } @Entity class City{ String cityName; } If i want to retrieve all the books, if i use classic JPA Repository and Spring Data and just do a findAll() , it will get me all the books with all the Authors with all their home towns. I know i can use @JsonIgnore , but i think that only prevents whats being returned, not whats being looked up in the database. And

Can't call PostgreSQL's 11 Stored Procedure with Hibernate

亡梦爱人 提交于 2020-01-30 05:26:12
问题 PostgreSQL 11 now supports stored procedures and I am trying to call one with Hibernate 5.3.7.Final and Postgresql 42.2.5 JDBC driver . Previous to PostgreSQL 11 we had functions that could be called with JPA's @NamedStoredProcedure . However, the functions were executed with SELECT my_func(); and the new stored procedures have to be executed with CALL my_procedure(); I am trying to execute the following simple stored procedure: CREATE OR REPLACE PROCEDURE p_raise_wage_employee_older_than

Audits with Spring Data Neo4j

一世执手 提交于 2020-01-29 09:44:07
问题 I'm currently working on a project that makes use of Spring Data Neo4j. Whenever a NodeEntity is created, I would like to create a referenced Audit NodeEntity that contains the creation date and user. A solution that I've come up with, is to write an AOP Aspect which hooks in on the create method of my service layer. This works fine for entities that aren't cascaded, but what about the cascaded ones? That are not explicitly passed in my service layer so my AOP class will not intercept them.

LazyInitializationException: could not initialize proxy - no Session

给你一囗甜甜゛ 提交于 2020-01-28 02:19:09
问题 I use spring-data-jpa with spring-boot(v2.0.0.RELEASE) , just write a CURD demo on MySQL, but it occurs an exception during runtime, source code as follows: Source code User.java @Entity public class User implements Serializable { private static final long serialVersionUID = 1L; @Id private Integer id; private String username; private String password; ...getter&setter } UserRepository.java public interface UserRepository extends JpaRepository<User, Integer> { } UserServiceTest.java @RunWith

LazyInitializationException: could not initialize proxy - no Session

走远了吗. 提交于 2020-01-28 02:17:35
问题 I use spring-data-jpa with spring-boot(v2.0.0.RELEASE) , just write a CURD demo on MySQL, but it occurs an exception during runtime, source code as follows: Source code User.java @Entity public class User implements Serializable { private static final long serialVersionUID = 1L; @Id private Integer id; private String username; private String password; ...getter&setter } UserRepository.java public interface UserRepository extends JpaRepository<User, Integer> { } UserServiceTest.java @RunWith

Postgresl select count(*) time-consuming

自古美人都是妖i 提交于 2020-01-25 04:41:07
问题 I am using spring-data-jpa & postgresql-9.4 . There is a table: tbl_oplog . This table has about seven million rows of data, and data is need to be displayed on the front end.(paged). I use Spring#PagingAndSortingRepository , and then I found that the data query was very slow. From the logs, I found that two SQL queries were issued: select oplog0_.id as id1_8_, oplog0_.deleted as deleted2_8_, oplog0_.result_desc as result_d3_8_, oplog0_.extra as extra4_8_, oplog0_.info as info5_8_, oplog0_