Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Feb 25, 2017 · 1 comment
Assignees
Labels
type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link

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)

@spring-projects-issues
Copy link
Author

Mark Paluch commented

Thanks for reporting this issue which is actually a bug. We have some code to determine dependencies between user-defined types to create types in Apache Cassandra in the right order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants