Craig Walls wrote:
What you've got here is quite similar to something I started to do about
a year ago to solve the same problem. The problem, restated, is : You
must feed LocalSessionFactoryBean a list of *.hbm.xml files for it to
load, but you'd rather not statically create that list. This is
especially important in a large system with dozens (or even hundreds) of
Hibernated beans.
But, then the Spring team went and did something that alleviated the
pain in an even better way: They let you set a list of mapping directory
locations...these are directories where *.hbm.xml files may be found.
So, instead of listing out all *.hbm.xml files statically in your Spring
configuration file, you can do something more like this:
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/myapp/domain/</value>
</list>
</property> <property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">mydialect</prop>
</props>
</property>
</bean>
In this case, it pulls all *.hbm.xml files that are contained within the
classpath and in the com.myapp.domain package. But you don't have to use
classpath references...any directory reference will do fine. And because
"mappingDirectoryLocations" can take a list, you can specify multiple
directories...but each directory can have many *.hbm.xml files in it
that are assumed to be loaded.
This is how I configure my spring bean factory, as well. Nice and neat.
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
xdoclet-user mailing list
xdoclet-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xdoclet-user