Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - Single Class to Multiple Tables

 
M Kramer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our group is working on a project in which we have identical tables with different names for the each month of the year. for example:
SALES_JAN
SALES_FEB
etc..
With the exception of the table name, the stucture of all of the tables are identical.

Because the potential size of the tables, our dba wants to drop and add the tables after a period to clear the data rather than delete rows.

I have a single class, say sales.java, and I want to specifiy the table at runtime to insert into. Is there a way to do this without having to create and maintain 12 hibernate mapping files and/or 12 separate java classes?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hate to say this, but yes there is a way. You can always build up SessionFactory from code.

But I personally don't like the DBA's decision here. With things like Oracle's partitioning and such, there is a much easier way to handle the month and old data thing than to model the database poorly.

Of course, if you show this to your DBA, he will curse me out, and ask what credentials do I have to question a DBA.

Mark
 
M Kramer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response
Unfortunately, we are locked into an antiquated proprietary database. This frustrates our DBA more than you can imagine.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by M Kramer:
Thanks for your response
Unfortunately, we are locked into an antiquated proprietary database. This frustrates our DBA more than you can imagine.


I can definitely imagine.

Mark
 
John Grath
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I disagree with the DBA's decision. With modern database technologies, you should be able to maintain large data sets in a better way. Instead of shoe horning in a Hibernate solution I would just use JDBC. As simple as that. If you're not going to be able to persist using Hiberate in this case; why use it to read the data? In conjunction with Spring, transactions can be shared across Jdbc and other database tools.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Grath:
I disagree with the DBA's decision. With modern database technologies, you should be able to maintain large data sets in a better way. Instead of shoe horning in a Hibernate solution I would just use JDBC. As simple as that. If you're not going to be able to persist using Hiberate in this case; why use it to read the data? In conjunction with Spring, transactions can be shared across Jdbc and other database tools.


John, that is what I said in the first reply, and if you read M's next reply he states that it isn't a decision that the DBA can make, that they are stuck with old database technology and cannot upgrade.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic