The phenomenon and background of the problem
BFCUSTOMITEM2022 The suffix of this table is year , New tables are used every year
Problem related code , Do not paste screenshots
@Query(value = "SELECT f.CUSITEMCODE FROM BFCUSTOMITEM2022 f WHERE f.ID = ?1", nativeQuery = true)
String queryAccountingProgramCode(String id);
Operation results and error reporting contents
This is a simple test I wrote
My solution ideas and tried methods
Use table name as parameter , Use ?1 and : Parameter name Pass in the table name , But the table name will be enclosed with a pair of quotation marks when querying , Lead to SQL Report errors
What I want to achieve
2022 The suffix of will change with the year
That's true. EntityManager, Because there are too many methods involved , I don't want to change it one by one