Hi,
If a datasource contains lot's of tables, should we make a sessionFactory for that datasource and write all the mappings for the tables OR should we define more sessionFactories for the datasource and write table mappings seperately...
Example: Are there any performance gains when using seperate sessionfactories as in the first example instead of the second one...
Ex1:
Ex2:Code:<bean id="sessionFactoryDB2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="DB2DataSource"/></property> <property name="mappingResources"> <list> <value>com/aaa/springtemplate/model/mapping/User.hbm.xml</value> <value>com/aaa/springtemplate/model/mapping/Order.hbm.xml</value> <value>com/aaa/springtemplate/model/mapping/Customer.hbm.xml</value> </list> </property> </bean>
Code:<bean id="sessionFactoryDB2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="DB2DataSource"/></property> <property name="mappingResources"> <list> <value>com/aaa/springtemplate/model/mapping/User.hbm.xml</value> </list> </property> </bean> <bean id="sessionFactory_2_DB2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="DB2DataSource"/></property> <property name="mappingResources"> <list> <value>com/aaa/springtemplate/model/mapping/Order.hbm.xml</value> </list> </property> </bean> <bean id="sessionFactory_3_DB2" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"><ref local="DB2DataSource"/></property> <property name="mappingResources"> <list> <value>com/aaa/springtemplate/model/mapping/Customer.hbm.xml</value> </list> </property> </bean>


Reply With Quote