S
S
sys_user2022-03-14 17:21:47
Java
sys_user, 2022-03-14 17:21:47

How to store and get sql queries from .properties file?

How to store and get sql queries from .properties file?
Only this comes to mind))

sql.properties file
user.get.all=select * from user

@PropertySource("classpath:sql.properties")
...
@Autowired
private Environment env;
...
String sql = env.getProperty("user.get.all");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2022-03-14
@xez

Sql queries, most likely, do not exist on their own, but are associated with some kind of model and business logic.
The model is in your code and the business logic is in the code, which means that the queries should be in the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question