com.scalar.db.sql.springdata.ScalarDbRepositoryImpl Maven / Gradle / Ivy
package com.scalar.db.sql.springdata;
import com.scalar.db.sql.springdata.twopc.ScalarDbTwoPcRepository;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.springframework.data.jdbc.core.JdbcAggregateOperations;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.repository.support.SimpleJdbcRepository;
import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.repository.CrudRepository;
/**
* Default implementation of {@link CrudRepository} and ${@link ScalarDbRepository} interface in the
* integration of Spring Data and ScalarDB.
*/
public class ScalarDbRepositoryImpl extends SimpleJdbcRepository
implements ScalarDbRepository, ScalarDbTwoPcRepository {
private final ScalarDbJdbcAggregateTemplate entityOperation;
@SuppressFBWarnings("EI_EXPOSE_REP2")
public ScalarDbRepositoryImpl(
JdbcAggregateOperations entityOperations,
PersistentEntity entity,
JdbcConverter converter) {
super(entityOperations, entity, converter);
if (!(entityOperations instanceof ScalarDbJdbcAggregateTemplate)) {
throw new IllegalArgumentException(
"entityOperations isn't ScalarDbJdbcAggregateTemplate: " + entityOperations);
}
this.entityOperation = (ScalarDbJdbcAggregateTemplate) entityOperations;
}
// For the SpotBugs warning CT_CONSTRUCTOR_THROW
@Override
protected final void finalize() {}
@Override
public T insert(T instance) {
return entityOperation.insert(instance);
}
@Override
public T update(T instance) {
return entityOperation.update(instance);
}
@Override
public String begin() {
return entityOperation.begin();
}
@Override
public void prepare() {
entityOperation.prepare();
}
@Override
public void validate() {
entityOperation.validate();
}
@Override
public void suspend() {
entityOperation.suspend();
}
@Override
public void commit() {
entityOperation.commit();
}
@Override
public void rollback() {
entityOperation.rollback();
}
@Override
public void join(String transactionId) {
entityOperation.join(transactionId);
}
@Override
public void resume(String transactionId) {
entityOperation.resume(transactionId);
}
}