aspose file tools*
The moose likes Object Relational Mapping and the fly likes HIbernate and virtual host Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "HIbernate and virtual host" Watch "HIbernate and virtual host" New topic
Author

HIbernate and virtual host

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi!

I have a war file that must work on 4 different domain names located on the same server.

domain1.com, domain1.se, domain2.com, domain2.se ( on the same server )

The model for these websites are exactly identical it is only lanuage and view that differs. The websites must be handled from one administration and I want to use Hibernate for ORM because they all point to the same database.

Is this possible? If I have virtual hosts in tomcat or JBoss it is 4 different instances of the war file that is loaded and what will happen with the data then? Can hibernate handle this? and how? Can this be done or do you suggest some other solution? It is vital that all stores can be administrated from one location.


SCJP1.4
Gaurav Bharadwaj
Greenhorn

Joined: Feb 06, 2008
Posts: 4
Hi,

I have seen such a situation.
Here we created a factory pattern for getting sessionFactory objects.
At the start of application the session factories for all the different data sources are created .
This factory is then used to initialise the session factory object by looking at some criteria like users Language from the context.
Thus for English the user can use session from english session factory or
he can use session from french session factory if he has FRENCH language in his user context.

[ February 06, 2008: Message edited by: Gaurav Bharadwaj ]
[ February 06, 2008: Message edited by: Gaurav Bharadwaj ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HIbernate and virtual host