|
Fornax-Platform
Forum |
« Return to Thread: Defining Datasource Properties.
Patrik Nordwall wrote:Three alternatives
Alternative 1.
You can define your own sessionFactory and datasource bean in more.xml
These will be used instead of the generated SesssionFactory.xml
If you find it confusing to have the sessionFactory bean defined in two places you can replace the the code generation like this...
Alternative 2.
To simply skip generation of SessionFactory.xml, and define it manually in src/main/resources you could can add this to SpecialCases.xpt:
«AROUND templates::Spring::sessionFactory FOR Application»
«ENDAROUND»
Alternative 3.
If you prefer to generate SessionFactory.xml with your own definition.
In SpecialCases.xpt:
«IMPORT sculptormetamodel»
«EXTENSION extensions::helper»
«EXTENSION extensions::properties»
«AROUND templates::Spring::sessionFactory FOR Application»
«EXPAND mySessionFactory»
«ENDAROUND»
«DEFINE mySessionFactory FOR Application»
«FILE getResourceDir("spring") + getApplicationContextFile("SessionFactory.xml") TO_GEN_RESOURCES-»
«EXPAND templates::Spring::header»
«IF isWar() -»
«EXPAND templates::Spring::txManager»
«ENDIF -»
«IF isJpaAnnotationToBeGenerated()»
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="configLocation" value="hibernate.cfg.xml"></property>
«ELSE»
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="myDataSource" />
</property>
«EXPAND templates::Spring::hibernateMappingResources»
«ENDIF»
<property name="entityInterceptor">
<ref bean="auditInterceptor" />
</property>
</bean>
<bean id="auditInterceptor" class="«auditInterceptorClass()»"/>
</beans>
«ENDFILE»
«ENDDEFINE»
Add myDataSource in more.xml
Using this technique it is possible to change the generated output of most things.
You need to look in the source code of the code generation templates to know what AROUNDs that can be done. Above is from Spring.xpt
/Patrik
« Return to Thread: Defining Datasource Properties.
| Free embeddable forum powered by Nabble | Forum Help |