Google

Locations of visitors to this page

Distributing mappings

ti-hibernate is a small layer ontop of the Hibernate configuration in the Spring framework, allowing to distribute configuration elements across subsystems.

The goal of ti-hibernate is to allow subsystem to only declare its entity mappings and to push it to a session factory configuration, breaking the monolithic configuration approach as it is offered by those technologies today.

ti-hibernate provides a simple way to distribute the mapping resources, mapping classes and hibernate properties needed to be registered into the session factory configuration.

A simple hibernate session factory configuration (example taken from the spring reference documentation ) is shown below:

<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource"/>
    <property name="mappingResources">
      <list>
        <value>product.hbm.xml</value>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.HSQLDialect
      </value>
    </property>
  </bean>
			

Even this simple configuration snippet shows that there are two different aspects beeing configured in the same bean:

  • Mappings
  • Properties
To distribute the configuration in different modules, ti-hibernate offers two configuration elements: <tiHibernate:mappings /> and <tiHibernate:properties />