英文:
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.EmailAddress,CQL类型:UDT(signature_data.emailaddress)
java.lang.IllegalArgumentException:The CQL ks.table: signature_data.signatures 定义在实体类中:com.salesforceiq.graph.sigparser.Signatures中声明了编解码器注册表不支持的类型映射:
Field: participants,实体类型:com.salesforceiq.graph.sigparser.EmailAddress,CQL类型: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("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;
}
}
I have following line in definition for my entity:
....
@Frozen
private List<EmailAddress> 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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论