java - Change Table Name of an Entity on runtime? -
there table being generated on monthly basis. table structure of monthly tables same.
since lot of work map same entity different table name,
is possible change table name of entity follows on runtime since have same table structure after all?
@entity @table(name="foo_jan2010") // other ways generate dynamically? public class foojan2010table { // if can dynamically set table name can named footable ... }
if not, approach can suggest?
is possible change table name of entity follows on runtime since have same table structure after all?
this not possible, @ least not standard jpa (which doesn't mean did non standard jpa) mentioned in questions such as:
- in @table(name = “tablename”) - make “tablename” variable in jpa
- jpa: how specify table name corresponding class @ runtime?
- hibernate or ibatis or else?
to summarize, jpa doesn't offer way "alter" given entity of initialized persistence unit (and related pre-compiled crud queries, pre-compiled named queries, etc).
still, since you're using hibernate, maybe have @ http://www.hibernate.org/171.html idea of possible using hibernate core api.
another option can think of use database synonym / alias: foo
alias foo_jan2010
until... change alias point on foo_feb2010
. i've never tested this, don't know if suit needs. it's idea.
Comments
Post a Comment