I noticed that calling createEntityManagerFactory(null)
will use the default Persistence Unit (PU) in the configuration file. Sometimes the classpaths get really messed up at deployment and I'd really like to see the name of the current PU for a given EntityManagerFactory. Is there any way to do this? Also, I would love to go so far as to see the entire properties map for the EntityManagerFactory.
views:
147answers:
1
A:
I found a way to do it if the provider is hibernate:
Session s=(Session)em.getDelegate();
//Get the URL.
String info=null;
try {
//The wonderful Hibernate team deprecated connection() before giving an alternative.
//Feel free to share the love at http://opensource.atlassian.com/projects/hibernate/browse/HHH-2603
//cf http://opensource.atlassian.com/projects/hibernate/browse/HHH-2603?focusedCommentId=29531&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_29531
info=s.connection().getMetaData().getURL();
} catch (Exception e) {
throw new RuntimeException(e);
}
//Finish
em.close();
return info;
Note that em
is an opened EntityManager created from an EntityManagerFactory. Also, like the comments? That's right, the Hibernate team is full of surprises again. Even though users gave feedback begging not to deprecate the only method that can help me, they are going full steam ahead. Note this link.
I'll upvote any good suggestions for a more stable JPA provider. Hibernate is just getting too unstable. This is definitely not the first issue of this kind that I had to workaround.
User1
2010-01-06 20:15:22