[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4857) Sharing metadata between different SessionFactories

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Sep 15 04:03:53 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43532#comment-43532 ] 

Emmanuel Bernard commented on HHH-4857:
---------------------------------------

Unfortunately with Hibernate Core 4 we dropped the ball on this set of patches.
It is still relevant with the work Steve and all have done on the Metamodel + Service split in Hibernate Core 4 which replaces the Configuration concept.
It is also relevant with the tenant id feature added in Hibernate Core 4.

There is certainly ideas to take from here and incorporate into the Hibernate Core 4 codebase. Let's discuss that on the hibernate-dev mailing list or even better on IRC (freenode #hibernate-dev).

> Sharing metadata between different SessionFactories
> ---------------------------------------------------
>
>                 Key: HHH-4857
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4857
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: core, entity-manager
>            Reporter: Chris Baxter
>            Assignee: Emmanuel Bernard
>            Priority: Minor
>         Attachments: anno.patch, AnnotationConfiguration.java, changes.txt, Configuration.java, core.patch, Ejb3Configuration.java, entitymanager.patch, SessionFactoryImpl.java, SharedAnnotationConfig.java
>
>
> In our system, we have each clients data in a separate DB instance. We're using JPA (via hibernate) on top of that to get at the data. The problem here is that for each client DB supported by one of our jboss servers, we have to have an instance of EntityManagerFactory compete with an Ejb3Configuration instance. Each config instance takes up around 20 MBs of permanent space, so if we have have 1000 client DBs supported by a jboss instance, it takes up a hugh amount of memory for information that will always be the same (the DB schemas are always the exact same in each client DB) across all EntityManagerFactory instances. So what I want to know is if there is a way to only have one instance of Ejb3Configuration that can be shared across all of the EntityManagerFactory instances that are spawning my EntityManagers. This would be huge as it would help me save many gigs of memory that never can be collected (old gen in jboss).
> I prototyped some changes locally to Ejb3Configuration (to allow an instance of AnnotationConfiguration to be supplied in the constructor, allowing sharing across all instanced of this class) and to SessionFactoryImpl (to share some of the properties like entityPersisters, classMetadata and such) and I was able to reduce the footprint to 20 MBs for the first DB and then under a MB for each additional DB.  The changes I made were a bit quick and dirty though, just to see if it was possible.  So I'm taking out this feature request to see if this is a piece of work that you guys can do (or I can contribute after refactoring to a more suitable approach) and integrate into the main code for hibernate-core and hibernate-entitymanager.  Let me know if this is something you guys think to be a valuable addition.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list