[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[News.eclipse.technology.eclipselink] JPA: adding entities to EntityManagerFactory programmatically
|
Hi,
my understanding of how to register entities that should participate
in the persistence mechanism, is that they need to be declared in
persistence.xml.
As in my case, there is an extension point to contribute entity
classes, I was looking for a way to programmatically add/register
entity classes to an EntityManagerFactory
All entity classes are known before the EntityManagerFactory has to
be created, but not at development-time.
I had a piece of code like the following in mind:
emf = Persistence.createEntityManagerFactory( "pu" );
// cast factory to EclipseLink implementation or similar
EclipseLinkEMF factory = emf;
// read class names from extension registry
Class[] entityCalsses = ...
for( int i = 0; i < entityClasses.length; i++ ) {
// make entity class known by EntityManagerFactory
factory.registerEntityClass( entityClasses[ i ] );
}
Thanks in advance
Rüdiger