Answer the question
In order to leave comments, you need to log in
How to fill a column in one table with data from a column in another table when the program starts?
There are two tables in MySQL:
a) event:
id | provider_id | client_id
1 | 1 | <null>
2 | 2 | <null>
3 | 2 | <null>
4 | 3 | 4
id | client_id
1 | 23
2 | 45
3 | 4
UPDATE event
INNER JOIN providers ON event.provider_id = providers.id
SET event.client_id = providers.client_id
Answer the question
In order to leave comments, you need to log in
You can simply declare a method annotated with @PostConstruct in any convenient bean and perform the necessary actions in it. It's only better to make this bean dependent on the EntityManager so that it doesn't get created earlier. Or declare an ApplicationListener that listens for the ContextRefreshedEvent. Only it is not clear why, the whole task looks like a crutch.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question