Skip to content

Support nested @UserDefinedType for schema creation [DATACASS-406] #573

Closed
@spring-projects-issues

Description

@spring-projects-issues

Michel Zanini opened DATACASS-406 and commented

Hi,

@UserDefinedType can be used to auto-create user types on schema generation.
However, it does not seem to be supported when a @UserDefinedType object has a property which is also a user defined type.

For example:

@Table
public class Trip {
  @Id
  UUID id;
  Destination destination;
}

@UserDefinedType
public class Destination {
  TimeZone timeZone;
}

@UserDefinedType
public class TimeZone {
  String timeZoneId;
  String timeZoneCode;
  String offset;
}

I have added a sample project attached which demonstrates the problem.
If schema generation is configured:
spring.data.cassandra.schema-action=RECREATE

Then the app will crash on startup trying to create the user defined types:

Caused by: org.springframework.data.mapping.model.MappingException: User type [timezone] not found

However, if schema generation is disabled:

spring.data.cassandra.schema-action=NONE

And the schema is created manually, then the mapping is supported and it read and save data correctly.

 id                                   | destination                                                                                                         | timezone
--------------------------------------+---------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------
 3b8628a1-fb8c-11e6-a469-27823ad07e50 | {latitude: -23.5, longitude: 84.43, timezone: {timezoneid: 'Europe/Dublin', timezonecode: 'IST', offset: '+01:00'}} | {timezoneid: 'Europe/Dublin', timezonecode: 'IST', offset: '+01:00'}

This nested structure is supported by Cassandra. By Spring Data is only supported if used without schema generation.

Can we support auto creation of these nested types for auto creating the schema, please?


Affects: 1.5.1 (Ingalls SR1), 2.0 M1 (Kay)

Attachments:

Referenced from: pull request #100

Backported to: 1.5.1 (Ingalls SR1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions