Skip to content

Cannot resolve table name since 3.4.2 #1293

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

Closed
mackatozis opened this issue Jul 22, 2022 · 3 comments
Closed

Cannot resolve table name since 3.4.2 #1293

mackatozis opened this issue Jul 22, 2022 · 3 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@mackatozis
Copy link

mackatozis commented Jul 22, 2022

Issue

We recently upgraded a module of ours to spring-data-cassandra 3.4.2 and our service is not able to identify any of the Cassandra tables when we are doing a query.

For example, when we try to insert a new entry to a table, we get the following exception:

 com.datastax.oss.driver.api.core.servererrors.InvalidQueryException: table SAMPLE does not exist

Full stacktrace:
https://gist.github.com/mackatozis/33f4dfae804d25b9f0f819ac575af34e

If we force our module to use spring-data-cassandra 3.4.1 everything works as expected.

Steps to reproduce

I have created a small demo that reproduces the issue:

https://github.com/mackatozis/cassandra-demo

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 22, 2022
@mp911de
Copy link
Member

mp911de commented Jul 22, 2022

We changed the naming behavior for user-provided identifiers. If you provide a table name, then we use the exact lettercasing and let Cassandra's driver's CqlIdentifier figure out whether the name must be quoted. It seems that your schema defines a table with the lowercase name sample. CREATE TABLE IF NOT EXISTS TEST_KEYSPACE.SAMPLE is being converted by Cassandra to CREATE TABLE IF NOT EXISTS test_keyspace.sample.

The fix is to use lowercase names in @Table (and any column annotations). The related changes were #1263 and #1281

@mackatozis
Copy link
Author

mackatozis commented Jul 22, 2022

By converting the name to lowercase, it has indeed fixed the issue.

Are there any plans to create a plugin that will scan the whole module and change the annotation values to lowercase? As of now, my company has hundreds of entities across multiple modules and it would be a tedious task to do the conversion.

@mp911de
Copy link
Member

mp911de commented Jul 22, 2022

Apologies for the inconvenience, we weren't aware that this change has such a wide negative impact. You could post-process entities and tables programmatically and set lowercase CQL identifiers via CassandraPersistentEntity.setTableName(…)/CassandraPersistentEntity.setColumnName(…). That could be an easier approach. Either by post-processing the MappingContext or even by subclassing MappingContext and post-processing each entity/property as it is being created.

@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 25, 2022
@mp911de mp911de closed this as completed Jul 25, 2022
@mp911de mp911de added status: invalid An issue that we don't feel is valid and removed status: declined A suggestion or change that we don't feel we should currently apply labels Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants