querydsl

Querydsl null-safe concatenation

若如初见. 提交于 2020-01-03 18:53:32
问题 Suppose you have the following data in table corresponding to the class Person , what is the correct way to search null-safely for the concatenation of fields name1 and name2 ? @Entity public class Person { Long id; String name1; String name2; // Getters and setters omitted for brevity } id | name1 | name2 ------------------------ 1 | Foo | null 2 | null | Bar 3 | Foo | Bar By default the concatentation of two columns results in null if either is null. public List<String> nameConcatenations()

QueryDSL, java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery;

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-02 08:18:11
问题 Trying to get Query Dsl (version 3.1.1) and Spring Data JPA (version 1.3.1.RELEASE) up and running.. My problem is with this error message ... java.lang.NoSuchMethodError: com.mysema.query.jpa.JPQLQuery.from([Lcom/mysema/query/types/EntityPath;)Lcom/mysema/query/jpa/JPQLCommonQuery; at org.springframework.data.jpa.repository.support.Querydsl.createQuery(Querydsl.java:88) at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.createQuery(QueryDslJ paRepository.java:131) Seems

Spring querydsl predicate: relationship support

不羁岁月 提交于 2020-01-01 18:54:50
问题 I have a Client entity with an OneToOne relation with Contact. If I want to get the client name, I need to write: client.getContact().getLastName() I use querydsl lib to filters client list in my spring boot app /api/clients?contact.lastName=Doe My controller signature: public ResponseEntity<ResponseListDTO> getClients ( @QuerydslPredicate(root = Client.class) Predicate predicateClient, Pageable pageable) It works well: predicate is well created and filters works. But now I need to filter on

Spring querydsl predicate: relationship support

我与影子孤独终老i 提交于 2020-01-01 18:54:14
问题 I have a Client entity with an OneToOne relation with Contact. If I want to get the client name, I need to write: client.getContact().getLastName() I use querydsl lib to filters client list in my spring boot app /api/clients?contact.lastName=Doe My controller signature: public ResponseEntity<ResponseListDTO> getClients ( @QuerydslPredicate(root = Client.class) Predicate predicateClient, Pageable pageable) It works well: predicate is well created and filters works. But now I need to filter on

Spring Data JPA and spring-security: filter on database level (especially for paging)

寵の児 提交于 2020-01-01 04:30:09
问题 I'm trying to add method level security to my open source project using annotations and spring-security. The problem I'm now facing are findAll methods especially the ones for Paging (eg. returning a page). Using @PostFilter works on Lists (but I personally believe its not a good idea to filter in application and not database) but completely fails on paging queries. This is problematic because I have an Entity containing List<Compound> . There are different implementations of compound and a

java.lang.NullPointerException: while filtering data using QueryDsl

浪尽此生 提交于 2019-12-31 05:09:06
问题 I am using Spring data jpa for creating service. In following code I am using Querydsl for implementing search filter on grid. But for building name I am not able to filter the grid. I am getting java.lang.NullPointerException: null . For grid data is coming from multiple tables. I am not using joining for that. I mapped models classes with each other @Service public class RoomTransferService { @Autowired RoomTransferRepository roomTransferRepo; @PersistenceContext EntityManager em; public

QueryDSL sorting not working with Spring Data

自古美人都是妖i 提交于 2019-12-31 03:35:11
问题 I am currently using JpaSort with Spring Data commons 1.9.1 and Spring JPA 1.7.1. I need to use QueryDSL because JPA does not allow defining the sort for null values. This is my Repository public interface DatasheetRepository extends JpaRepository<Datasheet, Long>, JpaSpecificationExecutor<Datasheet> I am doing this in my Controller: Page<Datasheet> page = m_datasheetRepository.findAll( new PageRequest( pageNumber, pageSize, createSortForDatasheets() ) ); This is what I had with JPA: private

JPQL / QueryDSL: join subquery and get aliased column

▼魔方 西西 提交于 2019-12-29 05:24:05
问题 I'm trying to get an average for a count on a groupBy by joining with a subquery. Don't know if that the right way to go at all but I couldn't anything about subqueries other than the mysema doc. Scenario: How many orders per product did a customer do on average? Meaning: A Customer orders products. So a customer ordered a specific product a number of times (count). What's the average number of orders that customer placed for any product? Might sound a bit hypothetical, in fact it's just part

Lazy Loading with QueryDsl/Hibernate not working

霸气de小男生 提交于 2019-12-25 09:09:23
问题 /** Parent Entity **/ @Entity @Table(name = "Parent") public class Parent { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "parentId", unique = true, nullable = false) private Integer parentId; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") @JsonManagedReference private Set<Child> childs = new HashSet<Child>(0); } ****** The Child Entity ****** @Entity @Table(name = "Child") public class Child { private static final long

Lazy Loading with QueryDsl/Hibernate not working

风流意气都作罢 提交于 2019-12-25 09:07:13
问题 /** Parent Entity **/ @Entity @Table(name = "Parent") public class Parent { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "parentId", unique = true, nullable = false) private Integer parentId; @OneToMany(fetch = FetchType.LAZY, mappedBy = "parent") @JsonManagedReference private Set<Child> childs = new HashSet<Child>(0); } ****** The Child Entity ****** @Entity @Table(name = "Child") public class Child { private static final long