有人可以帮我找出如何使用Spring
POJO 类插入 Cassandra UDT 数据吗?
我创建了一个 POJO 类来映射 Cassandra 的表并为 Cassandra UDT 创建了另一个类,但是当我插入映射 Cassandra 表的主要 POJO 类时,它无法识别另一个 POJO 类(映射 Cassandra 的 UDT)。我还在每个类和每个类对象上都写了注释。
这是我的一个 POJO 课程:-
package com.bdbizviz.smb.model.entity;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.mapping.Table;
import com.bdbizviz.smb.cassandra.udt.CoverPhoto;
import com.bdbizviz.smb.cassandra.udt.Location;
import com.bdbizviz.smb.cassandra.udt.MailingAddress;
import com.bdbizviz.smb.cassandra.udt.Reference;
import com.bdbizviz.smb.cassandra.udt.RestaurantServices;
import com.bdbizviz.smb.cassandra.udt.RestaurantSpecial;
import com.bdbizviz.smb.cassandra.udt.VoipInfo;
import com.datastax.driver.mapping.annotations.Frozen;
@Table("source")
public class Sources {
Integer likes;
Integer followers;
Integer rating;
String last_processedtime;
String filter_str;
String filter_type;
String category;
@PrimaryKeyColumn(ordinal=0,type=PrimaryKeyType.PARTITIONED)
String admin;
@PrimaryKeyColumn(ordinal=1,type=PrimaryKeyType.CLUSTERED)
String name;
@PrimaryKeyColumn(ordinal=2,type=PrimaryKeyType.CLUSTERED)
String source;
@PrimaryKeyColumn(ordinal=3,type=PrimaryKeyType.CLUSTERED)
Integer id;
@PrimaryKeyColumn(ordinal=4,type=PrimaryKeyType.CLUSTERED)
String type;
Integer delete_flag;
Integer evaluated;
@Frozen
Reference fb_reference_id_name ;
@Frozen
MailingAddress fb_mailingaddress;
@Frozen
CoverPhoto fb_coverphoto ;
@Frozen
VoipInfo fb_voipinfo;
@Frozen
RestaurantServices fb_restaurantservice;
@Frozen
RestaurantSpecial fb_restaurantspecialties;
@Frozen
Location fb_location;
/* Setter and Getter */
}
另一个 POJO 类:-
package com.bdbizviz.smb.cassandra.udt;
import org.springframework.data.annotation.Persistent;
import com.datastax.driver.mapping.annotations.Field;
import com.datastax.driver.mapping.annotations.UDT;
@UDT(name = "reference" ,keyspace="smb")
public class Reference {
@Field(name="id")
String id ;
@Field(name="name")
String name;
/* Setter and Getter */
}