-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Description
When we try to get a list of sorted entities, the order is lost if we use the EntityCallback.
I can confirm that the order is well respected in the AfterConvertCallback (I put a breakpoint in the onAfterConvert method and I can see each country sorted by countryName)
However, as the AfterConvertCallback is making some reactive call, the order is lost at the end and the method findAllByOrderByCountryName does not return an ordered flux anymore.
If I remove the EntityCallback, the sorting is well respected.
Entity country
public class Country {
@Id
private Long id;
@NotNull
private String countryName;
@Transient
private List<City> cities;
}
Country repository using ReactiveSorting
public interface CountryRepository extends ReactiveSortingRepository<Country, Long> {
Flux<Country> findAllByOrderByCountryName();
}
public interface CityRepository extends ReactiveCrudRepository<City, Long> {
Flux<City> findAllByCountryId(Long countryId);
}
@Component
@AllArgsConstructor
public class CountryAfterConvert implements AfterConvertCallback<Country> {
@Lazy
private final CityRepository cityRepository;
@Override
public Publisher<Country> onAfterConvert(Country entity, SqlIdentifier table) {
return cityRepository.findAllByCountryId(entity.getId())
.collectList()
.map(l -> {
entity.setCities(l);
return entity;
});
}
}
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug