I finallly got everything hooked up in eclipse to debug and see how the internals of hibernate work. I hooked up core, annotations, entitymanager, and jpa.
My problem occurs with jpa. when I step into it, the first thing I DO NOT see is it loading the persistence.xml file at all. Instead it is loading some PersistenceProvider.class in META-INF/services. Here is the code in Persistence.class.....(notice that there is no code that loads the persistence.xml but when I am using binary, it loads my persistence.xml file and Map properties allow me to override values....do I have the wrong source version from hibernate SVN or something????
public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
EntityManagerFactory emf = null;
if ( providers.size() == 0 ) {
findAllProviders();
}
for ( PersistenceProvider provider : providers ) {
emf = provider.createEntityManagerFactory( persistenceUnitName, properties );
if ( emf != null ) break;
}
if ( emf == null ) {
throw new PersistenceException( "No Persistence provider for EntityManager named " + persistenceUnitName );
}
return emf;
}
// Helper methods
private static void findAllProviders() {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Enumeration<URL> resources = loader.getResources( "META-INF/services/" + PersistenceProvider.class.getName() );
Set<String> names = new HashSet<String>();
while ( resources.hasMoreElements() ) {
URL url = resources.nextElement();
InputStream is = url.openStream();
try {
names.addAll( providerNamesFromReader( new BufferedReader( new InputStreamReader( is ) ) ) );
}
finally {
is.close();
}
}
for ( String s : names ) {
Class providerClass = loader.loadClass( s );
providers.add( (PersistenceProvider) providerClass.newInstance() );
}
}
catch (IOException e) {
throw new PersistenceException( e );
}
catch (InstantiationException e) {
throw new PersistenceException( e );
}
catch (IllegalAccessException e) {
throw new PersistenceException( e );
}
catch (ClassNotFoundException e) {
throw new PersistenceException( e );
}
}
|