omnifaces / optimusfaces

Utility library for OmniFaces + PrimeFaces combined

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Value based paging breaks when using DTOs ordered by a custom field

Edubits opened this issue · comments

When having a table which uses a DTO (extending the base entity) value based paging will break when the table is sorted by a field that only exists in the DTO. This happens because value based paging tries to find that field on the base entity.

Using the example from the PagedDataModel Javadoc this would be an order by YourEntityDTO::getTotalPrice.

Exception thrown:

Exception level 1: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at org.omnifaces.persistence.service.BaseEntityService.lambda$buildValueBasedPagingPredicate$37(BaseEntityService.java:1834)
	at java.util.Optional.orElseGet(Optional.java:267)