<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.mypackage.domain.Person</value>
</list>
</property>
</bean>
First i thought i found use xDoclet and generate this XML through the build process. But as I Googled up on the same i found that there was another way to do it in just one line which would scna all your sub packages. You just have to give your base package name and that its. Following is the re factored AnnotationSessionFactoryBean configuration;
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.mypackage.**.*</value>
</list>
</property>
</bean>
Thats it. Now you can put your domain classes anywhere within your project and this will scan all your entities.
No comments:
Post a Comment