Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hibernate Reactive support #392

Open
UbiquitousBear opened this issue Mar 1, 2024 · 0 comments
Open

Hibernate Reactive support #392

UbiquitousBear opened this issue Mar 1, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@UbiquitousBear
Copy link

Describe the solution you'd like
I would like JPAStreamer to be able to work with Hibernate Reactive, to perform non-blocking operations.

Describe alternatives you've considered
N/A

Additional context
Currently using Quarkus with Hibernate Reactive. I have repository as below, however, the operation itself is blocking.

@ApplicationScoped
@AllArgsConstructor
public class ComponentTypeRepository implements PanacheRepository<ComponentType> {
    private EntityManager entityManager;
    private final EntityReferenceDecoder entityReferenceDecoder;

    public Uni<List<ComponentType>> byIdSet(Set<EntityReference> entityReferenceSet) {
        return Uni.createFrom().item(getJPAStreamer().stream(ComponentType.class)
                .filter(ComponentType$.id.in(entityReferenceSet.stream().map(entityReferenceDecoder::getEntityIdFromReference).collect(Collectors.toSet())))
                .collect(Collectors.toList()));
    }

    protected JPAStreamer getJPAStreamer() {
        return JPAStreamer.createJPAStreamerBuilder(() -> entityManager).build();
    }
}

This code produces an exception:

SRGQL012000: Data Fetching Error: io.quarkus.runtime.BlockingOperationNotAllowedException: You have attempted to perform a blocking operation on a IO thread. This is not allowed, as blocking the IO thread will cause major performance issues with your application. If you want to perform blocking EntityManager operations make sure you are doing it from a worker thread.
	at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.checkBlocking(TransactionScopedSession.java:116)
	at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.getCriteriaBuilder(TransactionScopedSession.java:537)
	at org.hibernate.engine.spi.SessionLazyDelegator.getCriteriaBuilder(SessionLazyDelegator.java:699)
	at org.hibernate.engine.spi.SessionLazyDelegator.getCriteriaBuilder(SessionLazyDelegator.java:67)
	at org.hibernate.Session_OpdLahisOZ9nWRPXMsEFQmQU03A_Synthetic_ClientProxy.getCriteriaBuilder(Unknown Source)
	at com.speedment.jpastreamer.criteria.CriteriaFactory.createCriteria(CriteriaFactory.java:82)
	at com.speedment.jpastreamer.criteria.CriteriaFactory.createCriteria(CriteriaFactory.java:59)
	at com.speedment.jpastreamer.criteria.standard.StandardCriteriaFactory.createCriteria(StandardCriteriaFactory.java:44)
	at com.speedment.jpastreamer.renderer.standard.internal.StandardRenderer.render(StandardRenderer.java:99)
	at com.speedment.jpastreamer.builder.standard.internal.BaseStreamBuilder.renderResult(BaseStreamBuilder.java:183)
	at com.speedment.jpastreamer.builder.standard.internal.BaseStreamBuilder.renderAndThenApply(BaseStreamBuilder.java:122)
	at com.speedment.jpastreamer.builder.standard.internal.StreamBuilder.collect(StreamBuilder.java:192)
	at com.speedment.jpastreamer.autoclose.standard.internal.AutoClosingStream.lambda$collect$7(AutoClosingStream.java:177)
	at com.speedment.jpastreamer.autoclose.standard.internal.AbstractAutoClosingBaseStream.finallyClose(AbstractAutoClosingBaseStream.java:95)
	at com.speedment.jpastreamer.autoclose.standard.internal.AutoClosingStream.collect(AutoClosingStream.java:177)
	at net.shamil.dxtower.repositories.ComponentTypeRepository.byIdSet(ComponentTypeRepository.java:27)
@UbiquitousBear UbiquitousBear added the enhancement New feature or request label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants