Closed mykapp closed 5 years ago
The error message is very clear:
Data type '
frozen<"""TestUDT""".udt_details>' for column 'udt_details' of entity 'class com.mytest.TableWithUdt' does not match type in live schema '"TestUDT".udt_details'
The problem comes from your code:
@Frozen
@Column("udt_details")
private UdtDetails udtDetails;
The runtime schema does not match the mapping in the code
create table table_with_udt(
user_id text,
udt_id text,
udt_details udt_details, ---> NOT FROZEN HERE !
modification_date timestamp,
primary key((user_id), udt_id)
);
Hi, I am sorry but this is a bug. Because everything is working when I use a keyspace name in lowercase but not in uppercase.
Moreover 1) the annotation processor forces me to annotate the field "udt_details" with @Frozen, even if it is not a frozen in the schema. See the error below if I don't annotate the field with @Frozen in the class :
info.archinnov.achilles.exception.AchillesBeanMappingException: UDT class 'com.mytest.UdtDetails' in field 'udtDetails' of class 'com.mytest.TableWithUdt' should be annotated with @Frozen
at info.archinnov.achilles.internals.apt.AptUtils.validateTrue(AptUtils.java:507)
at info.archinnov.achilles.internals.parser.validator.cassandra2_1.NestedTypeValidator2_1.validate(NestedTypeValidator2_1.java:69)
at info.archinnov.achilles.internals.parser.FieldParser.parse(FieldParser.java:68)
2) even if I set the field as udt_details frozen<udt_details>
in the schema (and let the annotation @frozen in the class) I have an error with the message below :
Exception in thread "main" info.archinnov.achilles.exception.AchillesBeanMappingException: Data type 'frozen<"""TestUDT""".udt_details>' for column 'udt_details' of entity 'class com.mytest.TableWithUdt' does not match type in live schema 'frozen<"TestUDT".udt_details>'
at info.archinnov.achilles.validation.Validator.validateBeanMappingTrue(Validator.java:125)
at info.archinnov.achilles.internals.schema.SchemaValidator.validateColumns(SchemaValidator.java:120)
at info.archinnov.achilles.internals.metamodel.AbstractEntityProperty.validateSchema(AbstractEntityProperty.java:365)
at info.archinnov.achilles.internals.runtime.AbstractManagerFactory.lambda$validateSchema$539(AbstractManagerFactory.java:187)
So there is still the bug related to the validation of UDT used inside a keyspace whose name is in uppercase.
Regards, Mickaël
If you want to support unfrozen UDT, you can specify the CassandraVersion on your project compile time config: https://github.com/doanduyhai/Achilles/blob/master/achilles-model/src/main/java/info/archinnov/achilles/type/CassandraVersion.java#L294-L307
For the issue of comparing between code mapping and runtime, let me try to reproduce it
Ok issue successfully reproduced, attempting a fix
Bug fixed, will be available on next release
Good to know. Thanks.
Hi, When using a keyspace name in "Uppercase" and the schema contains an UDT, the schema validation fails with an error when comparing the datatype. It works correctly if the keyspace is in lowercase.
See the error below:
The database script is the following (also in the project in attachment):
The gradle example project with the annotated classes is in attachment.
myapptest.zip