openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: change entity mapping table in runtime
Date Thu, 11 Apr 2013 16:27:37 GMT
I'm not certain this is the right answer, but with a bit of hacking I was
able to get the behavior you are looking for....

// Get a reference to the mapping repository
MappingRepository repo = (MappingRepository) ((EntityManagerImpl)
em).getConfiguration().getMetaDataRepositoryInstance();
// Get a reference to the class mapping for the Entity we're interested in.
Note, you might need to pass the context classloader if running in a JEE
container.
ClassMapping customerMapping = repo.getMapping(Customer.class, null, true);

// Change the mapping info to use the 'new' table name
customerMapping.getTable().getIdentifier().setName("bas_person_2");

Be advised that the ClassMapping object is shared across the entire JPA
runtime... If you have multiple EntityManager's, changing the table
identifier name will impact every EM.

Hope this helps.

Thanks,
Rick

On Tue, Apr 2, 2013 at 10:49 PM, Alex <fiiexbl@gmail.com> wrote:

> Hello everyone,
>
> I'm going to WRITE/READ data into dozens of tables with the same
> constructure, different to ORACLE partition tables , my tables will be
> created in runtime. I want create only ONE entity to complete this task, is
> it possible to change the mapping table of an entity in runtime?
> Thanks a lot.
>
>
>
> Alex




-- 
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message