版本:Datastax Java驅動程序3.1.4,卡桑德拉3.10Datastax映射抱怨在生成插入重複列聲明
考慮下表:
create table object_ta
(
objid bigint,
version_date timestamp,
objecttype ascii,
primary key (objid, version_date)
);
而且映射類:
@Table(name = "object_ta")
public class ObjectTa
{
@Column(name = "objid")
private long objid;
@Column(name = "version_date")
private Instant versionDate;
@Column(name = "objecttype")
private String objectType;
public ObjectTa()
{
}
public ObjectTa(long objid)
{
this.objid = objid;
this.versionDate = Instant.now();
}
public long getObjId()
{
return objid;
}
public void setObjId(long objid)
{
this.objid = objid;
}
public Instant getVersionDate()
{
return versionDate;
}
public void setVersionDate(Instant versionDate)
{
this.versionDate = versionDate;
}
public String getObjectType()
{
return objectType;
}
public void setObjectType(String objectType)
{
this.objectType = objectType;
}
}
創建此類映射器後(mm
爲MappingManager
爲上的會話mykeyspace )
final Mapper<ObjectTa> mapper = mm.mapper(ObjectTa.class);
在調用
mapper.save(new ObjectTa(1));
我得到
查詢準備失敗:?INSERT INTO mykeyspace.object_ta (ObjID中的objid,version_date,OBJECTTYPE)VALUES(,, ?,?);: com.datastax.driver.core.exceptions.InvalidQueryException:列 名稱包含重複項 com.datastax.driver.core .Responses $ Error.asException(Responses.java:136) at com.datastax.driver.core.SessionManager $ 4.apply(SessionManager.java:220) at com.datastax.driver.core.SessionManager $ 4.apply (SessionManager.java:196) at com.google.common.util.concurrent.Futures $ ChainingListenableFuture.run(Futures.java:906) at com.google.common.util.concurrent.Futures $ 1 $ 1.run (Futures.java:635) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617) 在 io.netty.uti l.concurrent.DefaultThreadFactory $ DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) 在java.lang.Thread.run(Thread.java:745)
我茫然地理解,爲什麼重複objid
在查詢中生成。
非常感謝您提供問題的提示。
克萊門斯
這有助於在重新命名getter和setter以符合您的建議案例之後,它會起作用。非常感謝你! – Clemens