-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hibernate reactive panache refactoring
- do not store the current reactive session in the CDI request context but instead in the vertx duplicated context - do not offload execution of a panache entity method on the current vertx context but instead validate that the method is executed on the vetx duplicated context - introduce WithSession, WithSessionOnDemand and WithTransaction bindings and interceptors - deprecate ReactiveTransactional - ReactiveTransactionalInterceptor can only be used for methods that return Uni/Multi; this is validated at build time - if resteasy-reactive is present then automatically add WithSessionOnDemand binding to all resource methods on classes that use a panache entity - also remove the quarkus-integration-test-hibernate-reactive-panache-blocking module - quarkus-test-vertx - run the test method on a duplicated vertx context even if the RunOnVertxContext is not present but the TestReactiveTransaction is
- Loading branch information
Showing
36 changed files
with
1,125 additions
and
968 deletions.
There are no files selected for viewing
213 changes: 121 additions & 92 deletions
213
docs/src/main/asciidoc/hibernate-reactive-panache.adoc
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ommon/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/WithSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.hibernate.reactive.panache.common; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.interceptor.InterceptorBinding; | ||
|
||
/** | ||
* Instructs Panache to perform the work represented by the {@link io.smallrye.mutiny.Uni} returned from the intercepted method | ||
* within a scope of a reactive {@link org.hibernate.reactive.mutiny.Mutiny.Session}. | ||
* <p> | ||
* If a reactive session exists when the {@link io.smallrye.mutiny.Uni} returned from the annotated method is | ||
* triggered, then this session is reused. Otherwise, a new session is opened and eventually closed when the | ||
* {@link io.smallrye.mutiny.Uni} completes. | ||
* <p> | ||
* A method annotated with this annotation must return either {@link io.smallrye.mutiny.Uni}. If declared on a class then all | ||
* methods that are intercepted must return {@link io.smallrye.mutiny.Uni}. | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithSession { | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...ntime/src/main/java/io/quarkus/hibernate/reactive/panache/common/WithSessionOnDemand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.hibernate.reactive.panache.common; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.interceptor.InterceptorBinding; | ||
|
||
/** | ||
* Instructs Panache to trigger the {@link io.smallrye.mutiny.Uni} returned from the intercepted method within a scope of a | ||
* reactive {@link org.hibernate.reactive.mutiny.Mutiny.Session} (if needed). If a reactive session exists when the | ||
* {@link io.smallrye.mutiny.Uni} returned from the annotated method is triggered, then this session is reused. Otherwise, a new | ||
* session is opened <b>when needed</b> and eventually closed when the | ||
* {@link io.smallrye.mutiny.Uni} completes. | ||
* <p> | ||
* A method annotated with this annotation must return {@link io.smallrye.mutiny.Uni}. If declared on a class then all methods | ||
* that are intercepted must return {@link io.smallrye.mutiny.Uni}. | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithSessionOnDemand { | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...n/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/WithTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.hibernate.reactive.panache.common; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import jakarta.interceptor.InterceptorBinding; | ||
|
||
/** | ||
* Instructs Panache to trigger the {@link io.smallrye.mutiny.Uni} returned from the intercepted method within a scope of a | ||
* reactive {@link org.hibernate.reactive.mutiny.Mutiny.Transaction}. If a reactive session exists when the | ||
* {@link io.smallrye.mutiny.Uni} returned from the annotated method is triggered, then this session is reused. Otherwise, a new | ||
* session is opened and eventually closed when the | ||
* {@link io.smallrye.mutiny.Uni} completes. | ||
* <p> | ||
* A method annotated with this annotation must return {@link io.smallrye.mutiny.Uni}. If declared on a class then all methods | ||
* that are intercepted must return {@link io.smallrye.mutiny.Uni}. | ||
* | ||
* @see org.hibernate.reactive.mutiny.Mutiny.SessionFactory#withTransaction(java.util.function.Function) | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithTransaction { | ||
|
||
} |
Oops, something went wrong.