46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
package eu.eudat.dao.databaselayer.service;
|
|
|
|
|
|
import eu.eudat.dao.databaselayer.context.DatabaseContext;
|
|
import eu.eudat.entities.DataEntity;
|
|
import eu.eudat.queryable.QueryableList;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
|
|
@Service("databaseService")
|
|
public class DatabaseService<T extends DataEntity<T>> {
|
|
|
|
private DatabaseContext<T> databaseCtx;
|
|
|
|
@Autowired
|
|
public DatabaseService(DatabaseContext<T> databaseCtx) {
|
|
this.databaseCtx = databaseCtx;
|
|
}
|
|
|
|
public QueryableList<T> getQueryable(Class<T> tClass) {
|
|
return this.databaseCtx.getQueryable(tClass);
|
|
}
|
|
|
|
public QueryableList<T> getQueryable(Set<String> hints,Class<T> tClass) {
|
|
return this.databaseCtx.getQueryable(tClass).setHints(hints);
|
|
}
|
|
|
|
public T createOrUpdate(T item,Class<T> tClass) {
|
|
return this.databaseCtx.createOrUpdate(item, tClass);
|
|
}
|
|
|
|
public Long count(Class<T> tClass){
|
|
return this.databaseCtx.count(tClass);
|
|
}
|
|
|
|
public void delete(T item){
|
|
this.databaseCtx.delete(item);
|
|
}
|
|
|
|
}
|