Hi,
In my opinion this does sound possible via the Java Reflection API so long as you can extract/discover the classes that are managed by a particular persistence unit.
Once you have the class names, you can create a
.class, and then introspect it/them. Assuming you have the Object defined as a class level variable (with a particular variable name) you can call (not used the reflection API, so this might not be 100% acurate) <class object>.getFields() which will return the fields, then you have to loop over them checking for the one you are searching for.
Annother similar option would be to declare your own custom annotation and annotate the reference to the object you want to search for like so:
Code:
@MyCustomAnnotation
Obect foo
You can then use the reflection API to search for your custom annotation.
Hope that helps,
Andy