Heather,
Good question...  :-)  This topic has come up recently due to some potential
locking issues (serialized access) when reading the metadata repository in a
multi-threaded environment.  At this point, there is not a clear cut answer
for forcing the initialization of the metadata repository.  The code for the
new openjpa.InitializeEagerly property was committed to trunk last August
(after the 1.2.0 release was created), but we've since determined that it
may not be complete for all cases.  You are welcome to try it out from
either the 1.3.x or trunk branches and see if it helps in your particular
situation.

Let us know what you find out.  Also, can you explain your need for getting
this data eagerly vs letting the lazy loading process play out?  Thanks!

Kevin



On Mon, May 11, 2009 at 2:40 PM, Heather Sterling <hst...@us.ibm.com> wrote:

>
>
> 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: hst...@us.ibm.com

Reply via email to