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

-- 
View this message in context: 
http://www.nabble.com/Defining-Datasource-Properties.-tp23809982s17564p23820511.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Fornax-developer mailing list
Fornax-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fornax-developer

Reply via email to