Java Reference
In-Depth Information
<property name=" hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
The mappingResources property's type is String[] , so you can specify a set of mapping files in the
classpath. LocalSessionFactoryBean also allows you take advantage of Spring's resource-loading support
to load mapping files from various types of locations. You can specify the resource paths of the mapping
files in the mappingLocations property, whose type is Resource[] .
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
...
<property name=" mappingLocations">
<list>
<value>classpath:com/apress/springenterpriserecipes/course/
Course.hbm.xml</value>
</list>
</property>
...
</bean>
With Spring's resource-loading support, you can also use wildcards in a resource path to
match multiple mapping files so that you don't need to configure their locations every time you add
a new entity class. Spring's preregistered ResourceArrayPropertyEditor will convert this path into a
Resource array.
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
...
<property name=" mappingLocations"
value="classpath:com/apress/springenterpriserecipes/course/*.hbm.xml" />
...
</bean>
If your mapping metadata is provided through JPA annotations, you have to make use
of AnnotationSessionFactoryBean instead. You have to specify the persistent classes in the
annotatedClasses property of AnnotationSessionFactoryBean .
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.
annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name=" annotatedClasses">
<list>
<value>com.apress.springenterpriserecipes.course.Course</value>
</list>
</property>
Search WWH ::




Custom Search