Hi, I was faced with the problem of declaring an HB SessionFactory as a JMX service (using the HibernateService class) but I was impossibilitated from declaring mapped classes. Basically as it stands at the moment, the HibernateService MBean allows only to specify a mapResources property which is a comma separated list of .hbm.xml files. I changed the current service in order to allow another property (mappedClasses) which allows a comma separated list of @Entity classes which are loaded and mapped at runtime. It would be nice if this change would be included in future versions of Hibernate. This change involved the following:
1) To add two extra methods in the org.hibernate.jmx.HibernateServiceMBean interface (getter/setter for the new property)
2) To add another String attribute to org.hibernate.util.ExternalSessionFactoryConfig to contain the additional property
3) To create a new ConfigurationFactory class which creates standard configurations (Configuration) or configurations which support annotations (AnnotationConfiguration) depending if the new property contains any values (this property is mutually exclusive with the mapResources one)
The drawback is that AnnotationConfiguration is part of the hibernate-annotations artifact, so in order for this change to work, hibernate-annotations should be included in the hibernate/lib folder, introducing a dependency that maybe is unwanted. If you guys find a better way, feel free to change things around
As I said it would be nice to have this feature in the next HB release, so I'm happy to post/attach the code I've changed, just let me know how could I do that.
Don't know if I've got credit or if this post will be read, but if you have got the power to change things, to have the change please feel free to email me at: mtedone at jemos.co.uk or if I can attach the changes here, please just tell me how to do so.
Cheers.
M.
|