0
votes

I found the quarkus-hibernate-reactive-panache extension but I couldn't find an example of it using Panache orm with reactive repositories (In my case I use postgresql).

PanacheRepositoryBase.java seems that works as I need (smallrye.mutiny.*), could anybody link me to an example?

Thanks in advace, and nice work on quarkus project.

Regards

1
Waiting for the same here too. Tried to migrate an existing complex mapping to Reactive Hibernate but gets weird exceptions like "Caused by: org.hibernate.MappingException: Could not instantiate collection persister org.hibernate.reactive.persister.collection.impl.ReactiveOneToManyPersister". Searched it but Google god failed me!!Krishnakumar Ramachandran
Hi @KrishnaKumar, as a workarround we migrated to panacheRepositories and encapuslate all operations on Multi/Uni (smallrye) to maintain the reactive signature and behaviour. Is not the good approach, but for now ... public class MyEntityRepositoryImpl implements PanacheRepository<MyEntity>,MyEntityRepository { public Uni<MyEntity> findMyEntityById(Long id) { return Uni.createFrom().item(findById(id)).onItem().transform(mapper::toEntity); } But, you found the "could not instatiate..."error when building native image on quarkus?danipenaperez
Hi Dani, I got everything working here. My error was due to using "@ElementCollection" which the reactive hibernate doesn't support yet as per "github.com/hibernate/hibernate-reactive" Limitations section. But when I created the native image, the old exception is back again!! Yes, I am also returning Uni/Multi..... Trying to solve that now. No documentation or support is a major headache!!! . I am not using the Repository pattern but extending PanacheEntityBase for the entities.Krishnakumar Ramachandran
So yes, everything's working in quarkusDev but not in native image!!Krishnakumar Ramachandran
Thanks Dani, I am trying to solve the native image problem with the insight you provided. As I told that I extend PanacheEntityBase and use the find() and other findBy methods to fetch entities, but for persisting, the persist() method doesn't work as is. So I am injecting Mutiny.SessionFactory factory; and using its factory.withTransaction((session, transaction) -> {} ) methods for persisting. Curious to know how you deal with it.Krishnakumar Ramachandran

1 Answers

1
votes

UPDATE: A quickstart is now available on the Quarkus quickstarts development branch: https://github.com/quarkusio/quarkus-quickstarts/tree/development/hibernate-reactive-panache-quickstart

Old answer:

I've just created a new quickstart for Hibernate Reactive with Panache in Quarkus: https://github.com/quarkusio/quarkus-quickstarts/pull/809

Hopefully, it will be included soon in the list of quickstarts, but you can have a look already if you want to play with it.