File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Creating multiple/single SessionFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Creating multiple/single SessionFactory" Watch "Creating multiple/single SessionFactory" New topic

Creating multiple/single SessionFactory

Naresh Chaurasia
Ranch Hand

Joined: May 18, 2005
Posts: 361
I understand that creation of session factory is expensive operation. Now assuming that i have an application1 with 10 java bean that are persisted in db and application2 with 100 java beans to be persisted.

In the application1 hibernate1.cfg.xml i have specified the mapping of all the 10 java bean and in application2 hibernate2.cfg.xml i have specified the mapping of all the 100 java beans.

Now in application1, i create a session factory sf1 and in application2 i create a session factory sf2.

Does creation of sf1 requires same amount of resources and is as "expensive" as creation of sf2.

I am trying to figure this out as i have multiple db instance, and multiple session factories are created. I want to merge all these db instance to reduce the overhead of creation of multiple session factories.

Please advise

SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
I agree. Here's the link:
subject: Creating multiple/single SessionFactory
It's not a secret anymore!