liveBook · Manning

@userdefinedtype

As explained in Spring in Action, Sixth Edition

@UserDefinedType is a Spring Data Cassandra annotation that identifies a class as representing a Cassandra user-defined type.

@UserDefinedType marks a class as Cassandra user-defined type data. Use it when a table column stores structured values, such as ingredients inside a taco. section 4.1.3

Create a separate class rather than reusing an entity already annotated with @Table. The user-defined type can contain only the properties needed inside the column and need not mirror a table. section 4.1.3

Embedding ingredients in a taco

IngredientUDT uses @UserDefinedType("ingredient") and stores an ingredient name and type. Taco can then persist a list of these objects entirely inside its ingredients column.

How Spring in Action, Sixth Edition covers it

How deep it goes
Defines the annotation and class shape, then stops short of explaining framework internals or detailed Cassandra type configuration.
Examples
Uses IngredientUDT, TacoUDT, the tacos table, and a cqlsh result containing structured ingredient values.
What it assumes
Assumes familiarity with Java classes and Cassandra persistence annotations while distinguishing entities from embedded user-defined types.
What you can do after
Build it from scratch by defining a separate annotated class for structured Cassandra column data.
How it connects
Connects user-defined types with Cassandra tables, denormalization, entity mapping, collections, and CQL queries.

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.