使用Java中的Cassandra映射器与用户定义类型(UDT)。

huangapple go评论87阅读模式
英文:

Using cassandra mapper with UDT in java

问题

我是Cassandra的初学者遇到了以下问题我定义了一个简单的用户定义类型UDT)。

import com.datastax.oss.driver.api.mapper.annotations.CqlName;

@CqlName("emailaddress")
public class EmailAddress {
    private String name;
    private String email_address;

    public EmailAddress() {}
    public EmailAddress(String name, String emailAddress) {
        this.name = name;
        this.email_address = emailAddress;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmail_address() {
        return email_address;
    }

    public void setEmail_address(String email_address) {
        this.email_address = email_address;
    }
}

在我的实体定义中我有以下一行

....

@Frozen
private List<EmailAddress> participants;

.....

我创建了一个简单的Dao其中有一个save()方法但是当我尝试运行它时我遇到了以下错误

The CQL ks.table: signature_data.signatures 定义在实体类中com.salesforceiq.graph.sigparser.Signatures中声明了编解码器注册表不支持的类型映射
Field: participants实体类型com.salesforceiq.graph.sigparser.EmailAddressCQL类型UDT(signature_data.emailaddress)
java.lang.IllegalArgumentExceptionThe CQL ks.table: signature_data.signatures 定义在实体类中com.salesforceiq.graph.sigparser.Signatures中声明了编解码器注册表不支持的类型映射
Field: participants实体类型com.salesforceiq.graph.sigparser.EmailAddressCQL类型UDT(signature_data.emailaddress)

我可能错过了一些关于我的UDT的注解但是我无法弄清楚到底是哪一个注解
英文:

I am total novice with cassandra and have a following problem: I defined a simple UDT
import com.datastax.oss.driver.api.mapper.annotations.CqlName;

    @CqlName(&quot;emailaddress&quot;)
public class EmailAddress {
private String name;
private String email_address;
public EmailAddress() {}
public EmailAddress(String name, String emailAddress) {
this.name = name;
this.email_address = emailAddress;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String email_address) {
this.email_address = email_address;
}
}

I have following line in definition for my entity:

....

@Frozen
private List&lt;EmailAddress&gt; participants;

.....

I created simple Dao with one method save() but when I trying to run it I am getting following error

The CQL ks.table: signature_data.signatures defined in the entity class: com.salesforceiq.graph.sigparser.Signatures declares type mappings that are not supported by the codec registry:
Field: participants, Entity Type: com.salesforceiq.graph.sigparser.EmailAddress, CQL type: UDT(signature_data.emailaddress)
java.lang.IllegalArgumentException: The CQL ks.table: signature_data.signatures defined in the entity class: com.salesforceiq.graph.sigparser.Signatures declares type mappings that are not supported by the codec registry:
Field: participants, Entity Type: com.salesforceiq.graph.sigparser.EmailAddress, CQL type: UDT(signature_data.emailaddress)

I probably miss some annotation for my UDT but I can't figure out which one

答案1

得分: 4

我假设您已经使用@Entity对您的UDT类进行了注释。有关示例,请参阅Cassandra Java驱动程序的Entities页面。

它似乎在participants列上失败了。它的类型不受支持,因此您可能需要为其实现自定义编解码器。有关详细信息,请参阅自定义编解码器页面。干杯!

英文:

I'm assuming you annotated your UDT class with @Entity. See the Entities page of the Cassandra Java driver for an example.

It appears to fail on the participants column. Its type isn't supported so you might need to implement a custom codec for it. See the Custom codecs page for details. Cheers!

huangapple
  • 本文由 发表于 2020年9月16日 11:00:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/63912487.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定