-
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; 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
- Loading branch information
Showing
28 changed files
with
909 additions
and
793 deletions.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
...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,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 javax.interceptor.InterceptorBinding; | ||
|
||
import org.hibernate.reactive.mutiny.Mutiny; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
/** | ||
* Instructs Panache to trigger the {@link Uni} returned from the intercepted method within a scope of a reactive | ||
* {@link Mutiny.Session}. If a reactive session exists when the {@link 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 Uni} completes. | ||
* <p> | ||
* A method annotated with this annotation must return {@link Uni}. If declared on a class then all methods that are intercepted | ||
* must return {@link Uni}. | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithSession { | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...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,30 @@ | ||
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 javax.interceptor.InterceptorBinding; | ||
|
||
import org.hibernate.reactive.mutiny.Mutiny; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
/** | ||
* Instructs Panache to trigger the {@link Uni} returned from the intercepted method within a scope of a reactive | ||
* {@link Mutiny.Session} (if needed). If a reactive session exists when the {@link 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 Uni} completes. | ||
* <p> | ||
* A method annotated with this annotation must return {@link Uni}. If declared on a class then all methods that are intercepted | ||
* must return {@link Uni}. | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithSessionOnDemand { | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...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,33 @@ | ||
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 javax.interceptor.InterceptorBinding; | ||
|
||
import org.hibernate.reactive.mutiny.Mutiny; | ||
import org.hibernate.reactive.mutiny.Mutiny.SessionFactory; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
|
||
/** | ||
* Instructs Panache to trigger the {@link Uni} returned from the intercepted method within a scope of a reactive | ||
* {@link Mutiny.Transaction}. If a reactive session exists when the {@link 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 Uni} | ||
* completes. | ||
* <p> | ||
* A method annotated with this annotation must return {@link Uni}. If declared on a class then all methods that are intercepted | ||
* must return {@link Uni}. | ||
* | ||
* @see SessionFactory#withTransaction(java.util.function.Function) | ||
*/ | ||
@Inherited | ||
@InterceptorBinding | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(value = RetentionPolicy.RUNTIME) | ||
public @interface WithTransaction { | ||
|
||
} |
Oops, something went wrong.