I am attempting to load all the persistent class metadata eagerly. I
realize this isn't great performance-wise, but I need to do it for the
time-being. I had wanted to call:
ClassMetaData[] classMetaDatas =
conf.getMetaDataRepositoryInstance().getMetaDatas();
but realized the data was loaded lazily when nothing came back. I switched
to using:);
Collection c = conf.getMetaDataRepositoryInstance().loadPersistentTypes(.
true, null);
which returned the classes to me, but getMetaDatas() still returned
nothing. Finally, I resorted to iterating through the class names, which
seemed to work.
Set names = conf.getMetaDataRepositoryInstance
().getPersistentTypeNames(false, null);
if (names != null) {
for (Iterator it = names.iterator(); it.hasNext();) {
String persistentClassname = (String)it.next();
System.out.println("Pre-loading metadata for: " +
persistentClassname);
try {
ClassMetaData cc = conf.getMetaDataRepositoryInstance
().getMetaData(Class.forName(persistentClassname), null, true);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I found a link regarding a potential openjpa property called
openjpa.InitializeEagerly (
https://issues.apache.org/jira/browse/OPENJPA-620) but it was never checked
into a release.
Given all these options, what is the correct way to load the metadata on
startup?
Heather Sterling
Systems Management Development
Phone: 919-254-7163 T/L: 444-7163
Cell: 919-423-3143
Email: [email protected]