-
-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
I am getting the following error when I add a sort query:
java.lang.NoClassDefFoundError: Could not initialize class io.github.perplexhub.rsql.jsonb.JsonbSupport. If I remove the sort query, the filter works.
Environment:
Spring Boot: 3.3.4
Java: 21
Dependencies:
dependencoes {
implementation("io.github.perplexhub:rsql-jpa-spring-boot-starter:6.0.23")
}My Model:
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "event")
public class Event {
...
@Column(nullable = false, unique = true, length = 50)
private String code;
...
}The code:
public Response<List<Event>> queryEvent(String filter, String sort, Integer first, Integer after) {
Specification<Event> specification = toSpecification(filter, sort);
Page<Event> eventPage = eventRepository.findAll(specification, toPageable(first, after));
return Response.<List<Event>>builder()
.data(eventPage .getContent())
.pageInfo(PageInfo.builder()
.hasNextPage(eventPage .hasNext())
.hasPreviousPage(eventPage .hasPrevious())
.startCursor(eventPage .getNumberOfElements() > 0
? eventPage .getContent().getFirst().getId()
: null)
.endCursor(eventPage .getNumberOfElements() > 0
? eventPage .getContent().getLast().getId()
: null)
.totalRecords(eventPage.getTotalElements())
.build())
.build();
}
public static <T> Specification<T> toSpecification(String rsqlQuery, String sortRsql) {
Specification<T> specification;
if (StringUtils.hasText(rsqlQuery)) {
specification = RSQLJPASupport.toSpecification(rsqlQuery);
if (StringUtils.hasText(sortRsql)) {
specification = specification.and(RSQLJPASupport.toSort(sortRsql));
}
} else if (StringUtils.hasText(sortRsql)) {
specification = RSQLJPASupport.toSort(sortRsql);
} else {
specification = null;
}
return specification;
}
public static Pageable toPageable(Integer first, Integer after) {
// Default to page 0 for page and 50 for pageSize in case the inputs have problems
return PageRequest.of(
after == null ? 0 : after,
first == null ? 50 : first
);
}This is the way I am calling the query method: queryEvent("", "version,asc", null, null);
Metadata
Metadata
Assignees
Labels
No labels