Datastax映射器在生成的插入语句

时间:2017-02-23 19:08:24

标签: cassandra datastax datastax-java-driver

版本:Datastax Java驱动程序3.1.4,Cassandra 3.10

考虑下表:

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 mykeyspace 上会话的MappingManager

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)     在   com.datastax.driver.core.SessionManager $ 4.适用(SessionManager.java:220)     在   com.datastax.driver.core.SessionManager $ 4.适用(SessionManager.java:196)     在   com.google.common.util.concurrent.Futures $ ChainingListenableFuture.run(Futures.java:906)     在   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.util.concurrent.DefaultThreadFactory $ DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)     在java.lang.Thread.run(Thread.java:745)

我无法理解,为什么在查询中生成了重复的objid

提前感谢你指出这个问题。

克莱门

0 个答案:

没有答案