spring-cassandra UDT data insert

mahendra singh

Can someone help me to find out how to insert Cassandra UDT data using Spring POJO class?

I created one POJO class to map Cassandra's Table and Created one another class for Cassandra UDT, but when i inserted main POJO class that map Cassandra's table than it's not recognized another POJO class( map Cassandra's UDT). I have also written anotation on every class and on every class object .

Here is My one POJO class :-

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 */
}

Another POJO class :-

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 */
}
Kaushal

Spring Cassandra Driver is not even support UDT feature. You have to use Cassandra's custom driver for this feature.

Here is the maven dependency for Cassandra Driver

<dependency>
    <groupId>com.datastax.cassandra</groupId>
    <artifactId>cassandra-driver-dse</artifactId>
    <version>2.1.6</version>
</dependency>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive