Skip to content

JdbcTemplate incorrectly generates an sql request #1722

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
bifrurcated opened this issue Jan 22, 2024 · 3 comments
Closed

JdbcTemplate incorrectly generates an sql request #1722

bifrurcated opened this issue Jan 22, 2024 · 3 comments
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Comments

@bifrurcated
Copy link

I have a project using jdbc and postgres. I have a schema.sql where the "usr" and "token" tables are created. The token table has the relationship "CONSTRAINT fk_token_user FOREIGN KEY ("user") PREFERENCES usr (id)". I switched from Spring Boot 2.7.5 to 3.1.2. When I make a findByEmail request, I get the error:
org.postgresql.util.PSQLException: ERROR: the token.usr column does not exist
Hint: Perhaps a reference to the "token.user" column was intended.
Position: 142
I have enabled the debug logs and different requests are being received:
Spring Boot 2.7.5: [SELECT "token"."issue_at" AS "issue_at", "token"."expired_at" AS "expired_at", "token"."refresh_token" AS "refresh_token" FROM "token" WHERE "token"."user" = ?]
Spring Boot 3.1.2: [SELECT "token"."issue_at" AS "issue_at", "token"."expired_at" AS "expired_at", "token"."refresh_token" AS "refresh_token" FROM "token" WHERE "token"."usr" = ?]

@bifrurcated bifrurcated changed the title JdbcTemplate incorrectly generates a request JdbcTemplate incorrectly generates a sql request Jan 22, 2024
@bifrurcated bifrurcated changed the title JdbcTemplate incorrectly generates a sql request JdbcTemplate incorrectly generates an sql request Jan 22, 2024
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 22, 2024
@mp911de
Copy link
Member

mp911de commented Jan 23, 2024

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Jan 23, 2024
@bifrurcated
Copy link
Author

twoDemoProjects.zip
Here are two perfectly identical projects, there is a test on version 2.7.5, it passes on new versions (3.1.2, 3.2.2), it does not pass

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 23, 2024
@bifrurcated
Copy link
Author

It was necessary to create a foreign key with the same name as the table. Apparently, in the old version, it was specified by the name of the class and did not take into account the @table(name) annotation

schauder pushed a commit that referenced this issue Apr 23, 2024
Introduce caching for configured RowMapper/ResultSetExtractor.

We now create RowMapper/ResultSetExtractor instances only once if they are considered static configuration.
A configured RowMapper ref/class is always static.
A configured ResultSetExtractor ref/class is static when the extractor does not accept a RowMapper or if the RowMapper is configured.

Default mappers or projection-specific ones require ResultSetExtractor recreation of the ResultSetExtractor is configured as Class.

Reuse TypeInformation as much as possible to avoid Class -> TypeInformation conversion.
Introduce LRU cache for DefaultAggregatePath to avoid PersistentPropertyPath lookups.
Introduce best-effort quoted cache for SqlIdentifier to avoid excessive string object creation.

Closes #1721
Original pull request #1722
schauder added a commit that referenced this issue Apr 23, 2024
Add author tags.

See #1721
Original pull request #1722
schauder pushed a commit that referenced this issue Apr 23, 2024
Introduce caching for configured RowMapper/ResultSetExtractor.

We now create RowMapper/ResultSetExtractor instances only once if they are considered static configuration.
A configured RowMapper ref/class is always static.
A configured ResultSetExtractor ref/class is static when the extractor does not accept a RowMapper or if the RowMapper is configured.

Default mappers or projection-specific ones require ResultSetExtractor recreation of the ResultSetExtractor is configured as Class.

Reuse TypeInformation as much as possible to avoid Class -> TypeInformation conversion.
Introduce LRU cache for DefaultAggregatePath to avoid PersistentPropertyPath lookups.
Introduce best-effort quoted cache for SqlIdentifier to avoid excessive string object creation.

Closes #1721
Original pull request #1722
schauder added a commit that referenced this issue Apr 23, 2024
Add author tags.

See #1721
Original pull request #1722
schauder added a commit that referenced this issue Apr 24, 2024
See #1721
Original pull request #1722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants