Shay-
Have you already obtained an EM from the EMF before you make this
call? If you try to get the metadatas after calling
emf.getEntityManager(), do you still see an empty list?
Also, note that unless you enumerate the classes in your
persistence.xml file (in the <class> elements), the only way the
system will be able to know about your classes before they are lazily
evaluated is if you enable one of the scanning features (e.g., but
packaging all your classes in a jar and specifying the <jar-file>
element in the persistence.xml, which will be automatically scanned
for persistent classes).
You might want to enable verbose logging and watch the make sure the
class metadatas are registered before you try to get the list from
the repository.
On Jan 1, 2007, at 4:11 PM, Shay Banon wrote:
Hi,
First, I hope that this is the correct forum for posting
questions, so
sorry if it isn't.
I have an external list of classes that I would like to match
against the
persistent classes that are defined/identified by OpenJPA. I would
really
like to get the ClassMetaData for each one, since it has a lot of
information that I could use. This intersection happens after the
EntityManagerFactory has been created.
I have tried using:ClassMetaData[] classMetaDatas =
emf.getConfiguration().getMetaDataRepositoryInstance().getMetaDatas();
But it seems like the meta data repository and ClassMetaData
information are
lazily loaded (i.e. when some operation is performed on a Class, the
relevant meta data is fetched if not found in cache). So, what I
get is an
empty array (even though I can see the OpenJPA identified the
classes).
I wonder how I would be able to get all the class meta data?
Something that I was thinking about is since I have the list of
classes that
I would like to check if they are persistent, I could call:
getMetaData(Class cls, ClassLoader envLoader, boolean mustExist), with
Thread context class loader and false in mustExists. I am guessing
that it
will load the ClassMetaData if not found. My main problem here is that
OpenJPA might be configured with a different class loader (though it
defaults to the thread context one).
Any suggestions?
p.s.
I am the author of Compass, so once I have this nailed down, we
will have
Search capabilities to OpenJPA ;)
--
View this message in context: http://www.nabble.com/Getting-all-the-
ClassMetaDatas-tf2905426.html#a8116958
Sent from the open-jpa-dev mailing list archive at Nabble.com.