You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Srinivas Sastry <sr...@gmail.com> on 2008/06/12 17:21:48 UTC
Facing Issues in updating data in dynamic table through OpenJPA
Hi,
I am facing issues in inserting data from a web application (Using
OpenJPA) into DB2 table which is renamed daily.
The issue is :
My Application reads data from a flat file every day and inserts into a
table whose name is like
* <<CONSTANT>> appended by <<YYYY_MM_DD>>*
So the table name changes everyday (the table will end with date on which
the data is inserted).
I am facing issue in implementing this in OpenJPA as the mappings are
already done in persistence.xml and cannot be changed. How can we make this
run time mapping to map the existing entity class to new table name?
I have explored few Options like Meet in the middle approach. But no luck as
these classes are mapped in class tag
I was able to get some pointers to connect with different user ids at run
times but could not find a way to update these classes in EntityManager
class.
Could anyone pls help me in resolving this issue?
Re: Facing Issues in updating data in dynamic table through OpenJPA
Posted by Jeremy Bauer <te...@gmail.com>.
Another option may be to create a "fixed-name" view or alias over your
existing table and then use that fixed-name within your JPA app. For
example, to create an alias with DB2:
CREATE ALIAS JPATBLALIAS FOR * <<CONSTANT>> appended by <<YYYY_MM_DD>>*;
Depending on how your new table gets created each day, you may be able
to modify your process to automatically drop the old and create a new
alias.
-Jeremy
Re: Facing Issues in updating data in dynamic table through OpenJPA
Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
Srinivas Sastry wrote:
> My Application reads data from a flat file every day and inserts into a
> table whose name is like
> * <<CONSTANT>> appended by <<YYYY_MM_DD>>*
>
> So the table name changes everyday (the table will end with date on which
> the data is inserted).
Maybe you could try to insert everything into <<CONSTANT>>_TEMP, and
thend use native SQL to rename the table?
Regards,
Ognjen