基本上我有这张table:
CREATE TABLE experiment(
experimentid varchar,
description text,
rt float,
intensity float,
mz float,
identifier text,
chemical_formula text,
filename text,
PRIMARY KEY ((experimentid),description, rt, intensity, mz, identifier, chemical_formula, filename)
);
使用experience.java
@Table(name= "experiment")
public class Experiment implements Serializable{
@PrimaryKey
private ExperimentKey experimentKey;
public ExperimentKey getExperimentKey() {
return experimentKey;
}
public void setExperimentKey(ExperimentKey experimentKey) {
this.experimentKey = experimentKey;
}
}
和experimentkey.java
@PrimaryKeyClass
public class ExperimentKey implements Serializable {
@PrimaryKeyColumn(name = "experimentid",ordinal = 0,type = PrimaryKeyType.PARTITIONED)
@CassandraType(type=DataType.Name.VARCHAR)
private String experimentid;
@PrimaryKeyColumn(name = "description",ordinal = 1)
@CassandraType(type=DataType.Name.VARCHAR)
private String description;
@PrimaryKeyColumn(name = "rt",ordinal = 2)
@CassandraType(type=DataType.Name.FLOAT)
private Float rt;
@PrimaryKeyColumn(name = "intensity",ordinal = 3)
@CassandraType(type=DataType.Name.FLOAT)
private Float intensity;
@PrimaryKeyColumn(name = "mz",ordinal = 4)
@CassandraType(type=DataType.Name.FLOAT)
private Float mz;
@PrimaryKeyColumn(name = "identifier",ordinal = 5)
@CassandraType(type=DataType.Name.VARCHAR)
private String identifier;
@PrimaryKeyColumn(name = "chemical_formula",ordinal = 6)
@CassandraType(type=DataType.Name.VARCHAR)
private String chemical_formula;
@PrimaryKeyColumn(name = "filename",ordinal = 7)
@CassandraType(type=DataType.Name.VARCHAR)
private String filename;
//getters and setters
public ExperimentKey(){
}
}
基本上我想通过crudrepository实现下面的查询:
Delete * from experiment where experimentid='(something)';
我知道我只能使用findallbyexperimentkey\u experimentid(experimentid)根据分区键进行选择,但是是否可以使用delete执行相同的操作?我尝试deleteallbyexperimentkey\u experimentid(experimentid),但出现错误:
无法使用带有参数的构造函数no\u构造函数示例化void
编辑1
好的,这是我的experimentrepo.java
public interface ExperimentRepo extends CrudRepository<Experiment,ExperimentKey>{
public void deleteAllByByExperimentKey_Experimentid(String expid);
}
这是我的experimentserviceimpl.java
@Service
public class ExperimentServiceImpl implements ExperimentService{
private ExperimentRepo experimentRepo;
@Autowired
public ExperimentServiceImpl(ExperimentRepo experimentRepo){
this.experimentRepo=experimentRepo;
}
@Override
public void deleteAllExperimentByExperimentid(String expid){
MapId id = id("experimentid", expid);
experimentRepo.deleteAllByByExperimentKey_Experimentid(expid);
}
不确定应该在哪里使用mapid id=id(“experimentid”,)。
暂无答案!
目前还没有任何答案,快来回答吧!