Skip to content

Fix #{#entityName} to return table name for native queries #3982

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

academey
Copy link

Fixes #3979

#{#entityName} was returning entity name instead of table name for native queries, causing failures with SELECT *.

Changes:

  • Add getTableName() to JpaEntityMetadata interface
  • Return table name for native queries, entity name for JPQL queries
  • Add test case

…name

Fixes spring-projects#3979

Native queries with SELECT * and #{#entityName} were failing because #{#entityName} was returning the entity name instead of the table name for native queries.

This change:
- Adds getTableName() method to JpaEntityMetadata interface with default implementation
- Makes #{#entityName} return table name for native queries and entity name for JPQL queries
- Removes instanceof checks for cleaner, type-safe code

Added test to verify the fix works correctly.

Signed-off-by: academey <[email protected]>
@academey academey force-pushed the fix/3979-native-query-spel-regression branch from b81c04a to c811561 Compare August 20, 2025 15:07
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BadJpqlGrammarException with native query using "select *" and #{#entityName}
2 participants