views:

23

answers:

1

Is there a way to programatically get Hibernate configuration parameter values, if I have access to a SessionFactory object?

I would like to list the configuration in a GUI view, for debuging purposes.

+1  A: 

If you cast your SessionFactory into the concrete SessionFactoryImpl implementation, then you'll have access to the properties coming from the Configuration through getProperties().

Pascal Thivent
Thx Pascal! Properties field is private in SessionFactoryImpl, I couldn't find a getter path to it, so I ripped it out with reflection, but it's working. Is there a more elegant way?
Robert
@Robert In Hibernate 3.5, there is `getProperties()` which is public. That's the version on which I based my answer. I don't have any better suggestion than reflection for previous versions.
Pascal Thivent