diff --git a/app/src/main/java/com/etesync/syncadapter/model/MyEntityDataStore.kt b/app/src/main/java/com/etesync/syncadapter/model/MyEntityDataStore.kt index 4df62d15..4ef9d39f 100644 --- a/app/src/main/java/com/etesync/syncadapter/model/MyEntityDataStore.kt +++ b/app/src/main/java/com/etesync/syncadapter/model/MyEntityDataStore.kt @@ -1,9 +1,60 @@ package com.etesync.syncadapter.model import io.requery.Persistable +import io.requery.meta.Attribute import io.requery.sql.Configuration import io.requery.sql.EntityDataStore +import java.util.concurrent.locks.ReentrantLock +import kotlin.concurrent.withLock class MyEntityDataStore(configuration: Configuration): EntityDataStore(configuration) { + val lock = ReentrantLock() + override fun insert(entity: E, keyClass: Class?): K { + lock.withLock { + return super.insert(entity, keyClass) + } + } + + override fun update(entity: E): E { + lock.withLock { + return super.update(entity) + } + } + + override fun update(entity: E, vararg attributes: Attribute<*, *>?): E { + lock.withLock { + return super.update(entity, *attributes) + } + } + + override fun upsert(entity: E): E { + lock.withLock { + return super.upsert(entity) + } + } + + override fun refresh(entity: E): E { + lock.withLock { + return super.refresh(entity) + } + } + + override fun refresh(entity: E, vararg attributes: Attribute<*, *>?): E { + lock.withLock { + return super.refresh(entity, *attributes) + } + } + + override fun refreshAll(entity: E): E { + lock.withLock { + return super.refreshAll(entity) + } + } + + override fun delete(entity: E): Void { + lock.withLock { + return super.delete(entity) + } + } } \ No newline at end of file