10000 [#1099] Add new interfaces for reactive values generation · hibernate/hibernate-reactive@81ec0e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81ec0e9

Browse files
committed
[#1099] Add new interfaces for reactive values generation
1 parent c4fa89a commit 81ec0e9

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* Hibernate, Relational Persistence for Idiomatic Java
2+
*
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Copyright: Red Hat Inc. and Hibernate Authors
5+
*/
6+
package org.hibernate.reactive.tuple;
7+
8+
import org.hibernate.Session;
9+
import org.hibernate.reactive.mutiny.Mutiny;
10+
import org.hibernate.tuple.ValueGenerator;
11+
12+
import io.smallrye.mutiny.Uni;
13+
14+
/**
15+
* A reactive {@link ValueGenerator} that gives access to a {@link Mutiny.Session}.
16+
* <p& 10000 gt;
17+
* This interface needs to extend {@link ValueGenerator} but Hibernate Reactive
18+
* ignores the method {@link MutinyValueGenerator#generateValue(Session, Object)}.
19+
* </p>
20+
*
21+
* @see StageValueGenerator
22+
*/
23+
public interface MutinyValueGenerator<T> extends ValueGenerator<T> {
24+
25+
@Override
26+
default T generateValue(Session session, Object owner) {
27+
throw new UnsupportedOperationException( "Use generateValue(Mutiny.Session, Object) instead" );
28+
}
29+
30+
Uni<T> generateValue(Mutiny.Session session, Object owner);
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Hibernate, Relational Persistence for Idiomatic Java
2+
*
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Copyright: Red Hat Inc. and Hibernate Authors
5+
*/
6+
package org.hibernate.reactive.tuple;
7+
8+
import java.util.concurrent.CompletionStage;
9+
10+
import org.hibernate.Session;
11+
import org.hibernate.reactive.stage.Stage;
12+
import org.hibernate.tuple.ValueGenerator;
13+
14+
/**
15+
* A reactive {@link ValueGenerator} that gives access to a {@link Stage.Session}.
16+
* <p>
17+
* This interface needs to extend {@link ValueGenerator} but the non reactive method is ignored by
18+
* Hibernate Reactive and, unless the default implementation is overridden, it will throw an exception
19+
* when called.
20+
* </p>
21+
*
22+
* @see MutinyValueGenerator
23+
*/
24+
public interface StageValueGenerator<T> extends ValueGenerator<T> {
25+
26+
@Override
27+
default T generateValue(Session session, Object owner) {
28+
throw new UnsupportedOperationException( "Use generateValue(Stage.Session, Object) instead" );
29+
}
30+
31+
CompletionStage<T> generateValue(Stage.Session session, Object owner);
32+
}

0 commit comments

Comments
 (0)
0