I defined a UDT POJO class as follows
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@UserDefinedType("address_type")
public class Address {
@Column("address_line")
@CassandraType(type = Name.TEXT)
private String addressLine;
@Column("postal_code")
@CassandraType(type = Name.TEXT)
private String postalCode;
@Column
@CassandraType(type = Name.TEXT)
private String city;
}
and also added this UDT definition on my keyspace for cassandra. My Entity with which I defined my UDT fields is
@Table("customer_model")
@Getter
@Setter
public class CustomerModel {
@PrimaryKey
private Integer id ;
@Column("company_name")
private String companyName;
@Column("company_email")
private String companyEmail;
@Column("tax_id")
private String taxId;
@Column("billing_address")
@CassandraType(type = Name.UDT,userTypeName = "address_type")
private Address billingAddress;
@CassandraType(userTypeName = "address_type", type = Name.UDT)
@Column("shipping_address")
private Address shippingAddress;
}
When I try to make basic CRUD operations I get following Exception ,
No converter found capable of converting from type [models.udt.Address] to type [com.datastax.oss.driver.api.core.data.UdtValue]
I tried to add Custom Converter implementations to no avail. How to make spring find suitable converters for my POJO UDT to Cssandra UDT type?
Similar problem was encountered here. How-to-use-userdefinedtypes Somehow when you annotate your UDT POJO with @UserDefinedType
, there is no need to annotate them again with @CassandraType
while using them as entity class fields.