【发布时间】:2018-06-02 19:48:22
【问题描述】:
我在我的项目中使用 spring + hibernate + oracle。我将 LocalSessionFactoryBean 作为会话工厂对象,并将不同的 hbm.xml 文件映射到我的项目中。
我的配置如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>one.hbm.xml</value>
<value>two.hbm.xml</value>
<value>three.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">....</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.connection.release_mode">after_transaction</prop>
<prop key="hibernate.transaction.auto_close_session">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
</props>
</property>
</bean>
现在我有三个映射文件,每个映射文件都引用不同的架构。因此,要映射架构名称,我可以在每个映射文件中提供名称,例如:
<hibernate-mapping schema="one">
但问题是我根据不同的环境有不同的架构名称。那么如何以编程方式对其进行配置。
【问题讨论】:
标签: java spring hibernate hibernate-mapping