|
| 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.mutiny.delegation; |
| 7 | + |
| 8 | +import io.smallrye.mutiny.Uni; |
| 9 | +import jakarta.persistence.CacheRetrieveMode; |
| 10 | +import jakarta.persistence.CacheStoreMode; |
| 11 | +import jakarta.persistence.EntityGraph; |
| 12 | +import jakarta.persistence.FlushModeType; |
| 13 | +import jakarta.persistence.LockModeType; |
| 14 | +import jakarta.persistence.TypedQueryReference; |
| 15 | +import jakarta.persistence.criteria.CriteriaBuilder; |
| 16 | +import jakarta.persistence.criteria.CriteriaDelete; |
| 17 | +import jakarta.persistence.criteria.CriteriaQuery; |
| 18 | +import jakarta.persistence.criteria.CriteriaUpdate; |
| 19 | +import jakarta.persistence.metamodel.Attribute; |
| 20 | +import org.hibernate.*; |
| 21 | +import org.hibernate.query.criteria.JpaCriteriaInsert; |
| 22 | +import org.hibernate.reactive.common.AffectedEntities; |
| 23 | +import org.hibernate.reactive.common.Identifier; |
| 24 | +import org.hibernate.reactive.common.ResultSetMapping; |
| 25 | +import org.hibernate.reactive.mutiny.Mutiny; |
| 26 | + |
| 27 | +import java.util.List; |
| 28 | +import java.util.function.Function; |
| 29 | + |
| 30 | +/** |
| 31 | + * Wraps a {@linkplain #delegate} session. |
| 32 | + * |
| 33 | + * @author Gavin King |
| 34 | + */ |
| 35 | +public abstract class MutinySessionDelegator implements Mutiny.Session { |
| 36 | + |
| 37 | + public abstract Mutiny.Session delegate(); |
| 38 | + |
| 39 | + public <T> Uni<T> find(Class<T> entityClass, Object id) { |
| 40 | + return delegate().find(entityClass, id); |
| 41 | + } |
| 42 | + |
| 43 | + public <T> Uni<T> find(Class<T> entityClass, Object id, LockModeType lockModeType) { |
| 44 | + return delegate().find(entityClass, id, lockModeType); |
| 45 | + } |
| 46 | + |
| 47 | + public <T> Uni<T> find(Class<T> entityClass, Object id, LockMode lockMode) { |
| 48 | + return delegate().find(entityClass, id, lockMode); |
| 49 | + } |
| 50 | + |
| 51 | + public <T> Uni<T> find(EntityGraph<T> entityGraph, Object id) { |
| 52 | + return delegate().find(entityGraph, id); |
| 53 | + } |
| 54 | + |
| 55 | + public <T> Uni<List<T>> find(Class<T> entityClass, Object... ids) { |
| 56 | + return delegate().find(entityClass, ids); |
| 57 | + } |
| 58 | + |
| 59 | + public <R> Mutiny.SelectionQuery<R> createNamedQuery(String queryName, Class<R> resultType) { |
| 60 | + return delegate().createNamedQuery(queryName, resultType); |
| 61 | + } |
| 62 | + |
| 63 | + public <R> Mutiny.SelectionQuery<R> createQuery(String queryString, Class<R> resultType) { |
| 64 | + return delegate().createQuery(queryString, resultType); |
| 65 | + } |
| 66 | + |
| 67 | + public boolean isReadOnly(Object entityOrProxy) { |
| 68 | + return delegate().isReadOnly(entityOrProxy); |
| 69 | + } |
| 70 | + |
| 71 | + public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType, AffectedEntities affectedEntities) { |
| 72 | + return delegate().createNativeQuery(queryString, resultType, affectedEntities); |
| 73 | + } |
| 74 | + |
| 75 | + public boolean isDefaultReadOnly() { |
| 76 | + return delegate().isDefaultReadOnly(); |
| 77 | + } |
| 78 | + |
| 79 | + public <T> Uni<T> unproxy(T association) { |
| 80 | + return delegate().unproxy(association); |
| 81 | + } |
| 82 | + |
| 83 | + public Mutiny.MutationQuery createMutationQuery(String queryString) { |
| 84 | + return delegate().createMutationQuery(queryString); |
| 85 | + } |
| 86 | + |
| 87 | + public Uni<Void> close() { |
| 88 | + return delegate().close(); |
| 89 | + } |
| 90 | + |
| 91 | + public Mutiny.Session disableFetchProfile(String name) { |
| 92 | + return delegate().disableFetchProfile(name); |
| 93 | + } |
| 94 | + |
| 95 | + public <T> EntityGraph<T> getEntityGraph(Class<T> rootType, String graphName) { |
| 96 | + return delegate().getEntityGraph(rootType, graphName); |
| 97 | + } |
| 98 | + |
| 99 | + public <R> Mutiny.SelectionQuery<R> createSelectionQuery(String queryString, Class<R> resultType) { |
| 100 | + return delegate().createSelectionQuery(queryString, resultType); |
| 101 | + } |
| 102 | + |
| 103 | + public Uni<Void> refresh(Object entity, LockModeType lockModeType) { |
| 104 | + return delegate().refresh(entity, lockModeType); |
| 105 | + } |
| 106 | + |
| 107 | + public Uni<Void> lock(Object entity, LockModeType lockModeType) { |
| 108 | + return delegate().lock(entity, lockModeType); |
| 109 | + } |
| 110 | + |
| 111 | + public <R> Mutiny.Query<R> createQuery(TypedQueryReference<R> typedQueryReference) { |
| 112 | + return delegate().createQuery(typedQueryReference); |
| 113 | + } |
| 114 | + |
| 115 | + public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping, AffectedEntities affectedEntities) { |
| 116 | + return delegate().createNativeQuery(queryString, resultSetMapping, affectedEntities); |
| 117 | + } |
| 118 | + |
| 119 | + public Uni<Void> lock(Object entity, LockMode lockMode) { |
| 120 | + return delegate().lock(entity, lockMode); |
| 121 | + } |
| 122 | + |
| 123 | + @Incubating |
| 124 | + public <T> Uni<T> find(Class<T> entityClass, Identifier<T> naturalId) { |
| 125 | + return delegate().find(entityClass, naturalId); |
| 126 | + } |
| 127 | + |
| 128 | + public <T> Uni<T> withTransaction(Function<Mutiny.Transaction, Uni<T>> work) { |
| 129 | + return delegate().withTransaction(work); |
| 130 | + } |
| 131 | + |
| 132 | + public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, ResultSetMapping<R> resultSetMapping) { |
| 133 | + return delegate().createNativeQuery(queryString, resultSetMapping); |
| 134 | + } |
| 135 | + |
| 136 | + public <T> EntityGraph<T> createEntityGraph(Class<T> rootType, String graphName) { |
| 137 | + return delegate().createEntityGraph(rootType, graphName); |
| 138 | + } |
| 139 | + |
| 140 | + public Mutiny.Transaction currentTransaction() { |
| 141 | + return delegate().currentTransaction(); |
| 142 | + } |
| 143 | + |
| 144 | + public Mutiny.Session detach(Object entity) { |
| 145 | + return delegate().detach(entity); |
| 146 | + } |
| 147 | + |
| 148 | + public Mutiny.Session setCacheStoreMode(CacheStoreMode cacheStoreMode) { |
| 149 | + return delegate().setCacheStoreMode(cacheStoreMode); |
| 150 | + } |
| 151 | + |
| 152 | + public FlushMode getFlushMode() { |
| 153 | + return delegate().getFlushMode(); |
| 154 | + } |
| 155 | + |
| 156 | + public LockMode getLockMode(Object entity) { |
| 157 | + return delegate().getLockMode(entity); |
| 158 | + } |
| 159 | + |
| 160 | + public <R> Mutiny.Query<R> createNamedQuery(String queryName) { |
| 161 | + return delegate().createNamedQuery(queryName); |
| 162 | + } |
| 163 | + |
| 164 | + public CriteriaBuilder getCriteriaBuilder() { |
| 165 | + return delegate().getCriteriaBuilder(); |
| 166 | + } |
| 167 | + |
| 168 | + public Mutiny.SessionFactory getFactory() { |
| 169 | + return delegate().getFactory(); |
| 170 | + } |
| 171 | + |
| 172 | + public <R> Mutiny.SelectionQuery<R> createNativeQuery(String queryString, Class<R> resultType) { |
| 173 | + return delegate().createNativeQuery(queryString, resultType); |
| 174 | + } |
| 175 | + |
| 176 | + public Mutiny.Session setSubselectFetchingEnabled(boolean enabled) { |
| 177 | + return delegate().setSubselectFetchingEnabled(enabled); |
| 178 | + } |
| 179 | + |
| 180 | + public Mutiny.Session setFlushMode(FlushMode flushMode) { |
| 181 | + return delegate().setFlushMode(flushMode); |
| 182 | + } |
| 183 | + |
| 184 | + public Uni<Void> remove(Object entity) { |
| 185 | + return delegate().remove(entity); |
| 186 | + } |
| 187 | + |
| 188 | + public Mutiny.Session setCacheMode(CacheMode cacheMode) { |
| 189 | + return delegate().setCacheMode(cacheMode); |
| 190 | + } |
| 191 | + |
| 192 | + public Filter enableFilter(String filterName) { |
| 193 | + return delegate().enableFilter(filterName); |
| 194 | + } |
| 195 | + |
| 196 | + public Mutiny.MutationQuery createMutationQuery(JpaCriteriaInsert<?> insert) { |
| 197 | + return delegate().createMutationQuery(insert); |
| 198 | + } |
| 199 | + |
| 200 | + public <R> Mutiny.Query<R> createNativeQuery(String queryString, AffectedEntities affectedEntities) { |
| 201 | + return delegate().createNativeQuery(queryString, affectedEntities); |
| 202 | + } |
| 203 | + |
| 204 | + public Mutiny.Session setReadOnly(Object entityOrProxy, boolean readOnly) { |
| 205 | + return delegate().setReadOnly(entityOrProxy, readOnly); |
| 206 | + } |
| 207 | + |
| 208 | + public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) { |
| 209 | + return delegate().createEntityGraph(rootType); |
| 210 | + } |
| 211 | + |
| 212 | + public Uni<Void> refreshAll(Object... entities) { |
| 213 | + return delegate().refreshAll(entities); |
| 214 | + } |
| 215 | + |
| 216 | + public Mutiny.MutationQuery createMutationQuery(CriteriaDelete<?> deleteQuery) { |
| 217 | + return delegate().createMutationQuery(deleteQuery); |
| 218 | + } |
| 219 | + |
| 220 | + public Integer getBatchSize() { |
| 221 | + return delegate().getBatchSize(); |
| 222 | + } |
| 223 | + |
| 224 | + public Uni<Void> refresh(Object entity, LockMode lockMode) { |
| 225 | + return delegate().refresh(entity, lockMode); |
| 226 | + } |
| 227 | + |
| 228 | + public <T> T getReference(Class<T> entityClass, Object id) { |
| 229 | + return delegate().getReference(entityClass, id); |
| 230 | + } |
| 231 | + |
| 232 | + public <T> T getReference(T entity) { |
| 233 | + return delegate().getReference(entity); |
| 234 | + } |
| 235 | + |
| 236 | + public Mutiny.Session setBatchSize(Integer batchSize) { |
| 237 | + return delegate().setBatchSize(batchSize); |
| 238 | + } |
| 239 | + |
| 240 | + public Uni<Void> refresh(Object entity) { |
| 241 | + return delegate().refresh(entity); |
| 242 | + } |
| 243 | + |
| 244 | + public CacheMode getCacheMode() { |
| 245 | + return delegate().getCacheMode(); |
| 246 | + } |
| 247 | + |
| 248 | + public Uni<Void> mergeAll(Object... entities) { |
| 249 | + return delegate().mergeAll(entities); |
| 250 | + } |
| 251 | + |
| 252 | + public Uni<Void> persist(Object object) { |
| 253 | + return delegate().persist(object); |
| 254 | + } |
| 255 | + |
| 256 | + public boolean contains(Object entity) { |
| 257 | + return delegate().contains(entity); |
| 258 | + } |
| 259 | + |
| 260 | + public Mutiny.MutationQuery createMutationQuery(CriteriaUpdate<?> updateQuery) { |
| 261 | + return delegate().createMutationQuery(updateQuery); |
| 262 | + } |
| 263 | + |
| 264 | + public int getFetchBatchSize() { |
| 265 | + return delegate().getFetchBatchSize(); |
| 266 | + } |
| 267 | + |
| 268 | + public Mutiny.Session setDefaultReadOnly(boolean readOnly) { |
| 269 | + return delegate().setDefaultReadOnly(readOnly); |
| 270 | + } |
| 271 | + |
| 272 | + public Mutiny.Session clear() { |
| 273 | + return delegate().clear(); |
| 274 | + } |
| 275 | + |
| 276 | + public <E, T> Uni<T> fetch(E entity, Attribute<E, T> field) { |
| 277 | + return delegate().fetch(entity, field); |
| 278 | + } |
| 279 | + |
| 280 | + public <R> Mutiny.SelectionQuery<R> createQuery(CriteriaQuery<R> criteriaQuery) { |
| 281 | + return delegate().createQuery(criteriaQuery); |
| 282 | + } |
| 283 | + |
| 284 | + public Mutiny.Session setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) { |
| 285 | + return delegate().setCacheRetrieveMode(cacheRetrieveMode); |
| 286 | + } |
| 287 | + |
| 288 | + public Uni<Void> removeAll(Object... entities) { |
| 289 | + return delegate().removeAll(entities); |
| 290 | + } |
| 291 | + |
| 292 | + public Filter getEnabledFilter(String filterName) { |
| 293 | + return delegate().getEnabledFilter(filterName); |
| 294 | + } |
| 295 | + |
| 296 | + public void disableFilter(String filterName) { |
| 297 | + delegate().disableFilter(filterName); |
| 298 | + } |
| 299 | + |
| 300 | + public <R> Mutiny.MutationQuery createQuery(CriteriaDelete<R> criteriaDelete) { |
| 301 | + return delegate().createQuery(criteriaDelete); |
| 302 | + } |
| 303 | + |
| 304 | + public Mutiny.Session enableFetchProfile(String name) { |
| 305 | + return delegate().enableFetchProfile(name); |
| 306 | + } |
| 307 | + |
| 308 | + public <T> ResultSetMapping<T> getResultSetMapping(Class<T> resultType, String mappingName) { |
| 309 | + return delegate().getResultSetMapping(resultType, mappingName); |
| 310 | + } |
| 311 | + |
| 312 | + public Uni<Void> flush() { |
| 313 | + return delegate().flush(); |
| 314 | + } |
| 315 | + |
| 316 | + public Uni<Void> persist(String entityName, Object object) { |
| 317 | + return delegate().persist(entityName, object); |
| 318 | + } |
| 319 | + |
| 320 | + public <R> Mutiny.Query<R> createNativeQuery(String queryString) { |
| 321 | + return delegate().createNativeQuery(queryString); |
| 322 | + } |
| 323 | + |
| 324 | + public boolean isFetchProfileEnabled(String name) { |
| 325 | + return delegate().isFetchProfileEnabled(name); |
| 326 | + } |
| 327 | + |
| 328 | + public <T> Uni<T> merge(T entity) { |
| 329 | + return delegate().merge(entity); |
| 330 | + } |
| 331 | + |
| 332 | + public boolean isSubselectFetchingEnabled() { |
| 333 | + return delegate().isSubselectFetchingEnabled(); |
| 334 | + } |
| 335 | + |
| 336 | + public <R> Mutiny.MutationQuery createQuery(CriteriaUpdate<R> criteriaUpdate) { |
| 337 | + return delegate().createQuery(criteriaUpdate); |
| 338 | + } |
| 339 | + |
| 340 | + public Mutiny.Session setFetchBatchSize(int batchSize) { |
| 341 | + return delegate().setFetchBatchSize(batchSize); |
| 342 | + } |
| 343 | + |
| 344 | + public <T> Uni<T> fetch(T association) { |
| 345 | + return delegate().fetch(association); |
| 346 | + } |
| 347 | + |
| 348 | + public Uni<Void> persistAll(Object... entities) { |
| 349 | + return delegate().persistAll(entities); |
| 350 | + } |
| 351 | + |
| 352 | + @Deprecated |
| 353 | + public <R> Mutiny.Query<R> createQuery(String queryString) { |
| 354 | + return delegate().createQuery(queryString); |
| 355 | + } |
| 356 | + |
| 357 | + public Mutiny.Session setFlushMode(FlushModeType flushModeType) { |
| 358 | + return delegate().setFlushMode(flushModeType); |
| 359 | + } |
| 360 | + |
| 361 | + public boolean isOpen() { |
| 362 | + return delegate().isOpen(); |
| 363 | + } |
| 364 | +} |
0 commit comments