In my application we are using database table to store all the log. But now there is a change in requirement and instead of storing all the log related data in one table we have to create a table for that particular day and will have to store all the user logs int the table for that day....for Eg if today's date is 10 Aug then for storing a log a new database table will be created log_10_aug and all the data related to the current day will be stored in it... for next day again a new table will be created for storing the next day log activity..
We are using the Hibernate ORM in our application.....
Can someone let me know how to achieve the same using hibernate....how can we create the table dynamically with dynamic name....using hibernate...intent is that table strucuture will remain same however for each day the table name will be differenct (log_ preceeded by current date) ..
Why would you want separate tables? Why not just select by the date the log-entry was created? If it is for performance reasons (i.e. your table has millions and millions of rows (and even then ...)) why not move the rows to another table once every x days.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
@Vijay Tidake, Your code shows how to create dynamic tables, but once these tables are created, how will i access them, I mean i need to create hbm files and also, i should include it in the hibernate.cfg file. How will I do that?
Vijay Tidake wrote:Hi,
I'm following may be one way to create the table at run time using hibernate.