openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heather Sterling <>
Subject correct way to load persistent metadata at startup
Date Mon, 11 May 2009 19:40:12 GMT

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 =

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);
                    System.out.println("Pre-loading metadata for: " +
                    try {
                    ClassMetaData cc = conf.getMetaDataRepositoryInstance
().getMetaData(Class.forName(persistentClassname), null, true);
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block


I found a link regarding a potential openjpa property called
openjpa.InitializeEagerly ( but it was never checked
into a release.

Given all these options, what is the correct way to load the metadata on

Heather Sterling
Systems Management Development
Phone:  919-254-7163 T/L: 444-7163
Cell: 919-423-3143
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message