|
| 1 | +package tech.ydb.data.repository.support; |
| 2 | + |
| 3 | +import org.springframework.data.jdbc.core.JdbcAggregateOperations; |
| 4 | +import org.springframework.data.jdbc.core.convert.JdbcConverter; |
| 5 | +import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository; |
| 6 | +import org.springframework.data.mapping.PersistentEntity; |
| 7 | +import org.springframework.transaction.annotation.Transactional; |
| 8 | +import tech.ydb.data.repository.YdbCrudRepository; |
| 9 | +import tech.ydb.data.repository.YdbPagingAndSortingRepository; |
| 10 | + |
| 11 | +/** |
| 12 | + * @author Madiyar Nurgazin |
| 13 | + */ |
| 14 | +@Transactional(readOnly = true) |
| 15 | +public class SimpleYdbJdbcRepository<T, ID> extends SimpleJdbcRepository<T, ID> |
| 16 | + implements YdbCrudRepository<T, ID>, YdbPagingAndSortingRepository<T, ID> { |
| 17 | + private final JdbcAggregateOperations entityOperations; |
| 18 | + |
| 19 | + public SimpleYdbJdbcRepository( |
| 20 | + JdbcAggregateOperations entityOperations, PersistentEntity<T, ?> entity, JdbcConverter converter |
| 21 | + ) { |
| 22 | + super(entityOperations, entity, converter); |
| 23 | + this.entityOperations = entityOperations; |
| 24 | + } |
| 25 | + |
| 26 | + @Transactional |
| 27 | + @Override |
| 28 | + public <S extends T> S insert(S entity) { |
| 29 | + return entityOperations.insert(entity); |
| 30 | + } |
| 31 | + |
| 32 | + @Transactional |
| 33 | + @Override |
| 34 | + public <S extends T> S update(S entity) { |
| 35 | + return entityOperations.update(entity); |
| 36 | + } |
| 37 | + |
| 38 | + @Transactional |
| 39 | + @Override |
| 40 | + public <S extends T> Iterable<S> insertAll(Iterable<S> entities) { |
| 41 | + return entityOperations.insertAll(entities); |
| 42 | + } |
| 43 | + |
| 44 | + @Transactional |
| 45 | + @Override |
| 46 | + public <S extends T> Iterable<S> updateAll(Iterable<S> entities) { |
| 47 | + return entityOperations.updateAll(entities); |
| 48 | + } |
| 49 | +} |
0 commit comments