Answer the question
In order to leave comments, you need to log in
How to connect to generated tables at runtime?
Good afternoon, can you please tell me if this will work?
The situation, there is a system which works with . The peculiarity of this system is that it periodically creates a new table, something like:
tableImportantResults_02022012
tableImportantResults_03022012
@Entity
@Table(name = TABLE)
public class Model{
public static string = Table;
@id
@Column(name = "id")
int id
}
Answer the question
In order to leave comments, you need to log in
Not strong in Heber, but according to Google, there is an option to use your own interceptor, which will dynamically change the table name https://javaaltaf.blogspot.com/2019/01/change-tabl...
public class CustomInterceptor extends EmptyInterceptor {
@Override
public String onPrepareStatement(String sql) {
System.err.println("Before Modifying SQL =" + sql);
sql = sql.replace("ATTENDANCE_1_2019 ", "ATTENDANCE_2_2019 ");
System.err.println("After Modifying SQL =" + sql);
return sql;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question