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