• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to create a dynamic table with dynamic name in hibernate....

 
john sal
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) ..
 
Vijay Tidake
Ranch Hand
Posts: 148
Hibernate Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm following may be one way to create the table at run time using hibernate.



Hope this helps
Thanks
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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.



Hope this helps
Thanks
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rebecca Green,

Is your question is same as Vijay Tidake's? If not please create new thread for yours'.
 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very much relevant to Vijay Tidake's post. I came up with this doubt after reading Vijay's post.

Vijitha Kumara wrote:Hi Rebecca Green,

Is your question is same as Vijay Tidake's? If not please create new thread for yours'.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As there's not much details given by the OP and no other solutions are discussed you may need to clarify your situation properly. I suggest you start a new thread with more details in it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic