...without actually reading and parsing the persistence.xml
I can retrieve the name of the persistence unit of an EntityManager using the p
You need to:
EntityManager to EntityManagerImpl (the Hibernate implementation)getFactory()EntityManagerFactory to HibernateEntityManagerFactorygetSessionFactory() and cast it to SessionFactoryImplgetConnectionProvider() and cast it to the correct implementation. You can see the implementations here. I'll assume that it's a DatasourceConnectionProvidergetDataSource() and you're done.Unfortunately, you must use the Hibernate API, as there's no way to retrieve the DataSource using the JPA API.