0 Replies Latest reply on Nov 20, 2008 3:50 AM by Alram Lechner

    using same entity with two different tables

    Alram Lechner Newbie


      i have the following question:

      i have the same table in two schema. (same columns, same primary key, same tablename, but in another schema) primary i wan't to read and store my entities in the first (primary) table. if the entry there is final, i want to write it in to the table in second schema and remove it from the primary schema.

      at the moment, i do not have the schema hardcoded via annotations in the entity class. it comes from datasource XML file, where the default schema is set via the JDBC URL. maybe i can define two persistence units with different default schemas. but i think that can't work, because one entity class can only be bound to one persistenceUnit (as fas as i know).

      at the moment i don't know, how i can realize this with JPA.

      another possible solution is, to rename the second table and put it into the primary schema. but how can i adjust the tablename at runtime?

      are there people they had similar problems? can anyone give me a hint, how this can be resolved?

      thanks to all!