openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heather Sterling <hst...@us.ibm.com>
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 =
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: hsterl@us.ibm.com
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message