-
Notifications
You must be signed in to change notification settings - Fork 310
Added schema validation on context startup #1466
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
Conversation
Thanks for having a look. The design requires a bit more thought and not everything should be a String
or Exception
. Design-wise, we should decouple validation from any factory beans for a clearer separation of concerns. Later on, once the validation part is fine, we can consider how to integrate validation into application startup.
For type resolution, I suggest you have a look at DefaultColumnTypeResolver
and SchemaFactory
, how data types are derived from properties.
Also, validation findings should be part of a model (ColumnNotFound
, TableNotFound
) along with references to the underlying CQL item/persistent property/persistent entity.
Let me know whether that helps.
@mp911de I have introduced a couple of changes in accordance to what you've said:
CassandraSchemaValidator
now acceptsCqlSession
directly instead ofCqlSessionFactoryBean
CassandraSchemaValidator
now also acceptsCassandraConverter
instead ofCassandraMappingContext
. This allwos gettingCassandraMappingContext
fromCassandraConverter
and also the creation ofDefaultColumnTypeResolver
instance using CassandraConverter`
But I do not fully understand wht you mean here:
Also, validation findings should be part of a model (ColumnNotFound, TableNotFound) along with references to the underlying CQL item/persistent property/persistent entity.
Can you please give me a glue what is your vision here? You want CassandraSchemaValidationProfile
to accept not String
objects as validation error messages but have an abstraction over a message, such as ColumnNotFound
and TableNotFound
and so on, am I correct?
51d0427
to
3da8a0b
Compare
I have rebased this PR. Any chance to review it? @mp911de
Currently, this ticket (and several other ones) is on pause because we're limited in bandwidth. We currently can only fix smaller bugs and I don't know when we will have more time for proper enhancements.
This is the PR to solve #764 issue.
The key takeaways in the PR: there is a new class, called
CassandraSchemaValidator
, that is validating Cassandra schema against existing entities in theMappingContext
. The keyspace where we expect the entities to show up is one that is configured to be used byCqlSession
(for now that is correct because we do not have a keyspace segregation for entities yet, see this ticket).The validation checks that:
P.S: I think it would be nice to add this as a bean to Cassandra auto-configuration to spring boot with some properties conditional annotations