PVG
10-02-2006, 12:22 AM
Hi,
I want to use the possibility to define my xml file shorter by using the abstract object definitions.
I'm using spring 1.0.2 and the integration with NHibernate. The Dao object here all extend from HibernateSupportDao
When I use the following xml configuration, I get an NHibernate Exception specifyin that it could not find the connection string setting.
<objects xmlns="http://www.springframework.net">
<object id="NVNInsuranceProductDatabasePublisher" parent="InsuranceProductDatabasePublisher">
<property name="ValidLanguages" value="nl-NL"/>
<property name="InsuranceDao.SessionFactory.DbProvider" ref="ProductDatabaseNVNDbProvider"/>
</object>
<object id="NVBInsuranceProductDatabasePublisher" parent="InsuranceProductDatabasePublisher">
<property name="ValidLanguages" value="nl-BE, fr-BE"/>
<property name="InsuranceDao.SessionFactory.DbProvider" ref="ProductDatabaseNVBDbProvider" />
</object>
<object id="InsuranceProductDatabasePublisher" type="ThomasCook.Ecom.ProductDatabase.Publish.Publishers .Insurances.ProductDatabaseInsurancePublisher, ThomasCook.Ecom.ProductDatabase" abstract="true">
<property name="LanguagePropertyExpression" value="Language"/>
<property name="InsuranceDao">
<object type="ThomasCook.Ecom.ProductDatabase.Publish.Dao.Implem entations.InsuranceDao, ThomasCook.Ecom.ProductDatabase">
<property name="SessionFactory">
<object parent="ProductDatabaseSessionFactory"/>
</property>
</object>
</property>
</object>
<object id="ProductDatabaseSessionFactory" type="Spring.Data.Orm.NHibernate.LocalSessionFactoryObje ct, Spring.Data.Orm.NHibernate" abstract="true" >
<property name="DbProvider">
<null/>
</property>
<!--Must be overridden by all concretes -->
<property name="MappingAssemblies">
<list>
<value>ThomasCook.Ecom.ProductDatabase</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<entry key="hibernate.show_sql" value="false" />
</dictionary>
</property>
</object>
<object id="ProductDatabaseNVBDbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${connection.NVBProductDatabaseDb}" />
</object>
<object id="ProductDatabaseNVNDbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${connection.NVNProductDatabaseDb}" />
</object>
</objects>
When I change the definition of the definition of the ProductDatabaseSessionFactory object not to include a null for the DbProvider property but a filled in value (eg a ref to ProductDatabaseNVNDbProvider), then I get an InvalidPropertyException "DbProvider" node can not be resolved for the specified root context.
Maybe this is something specific for the NHibertnate integration, since I have used this same setup in other places without any problem.
What are my alternatives here.
KR
Patrick
I want to use the possibility to define my xml file shorter by using the abstract object definitions.
I'm using spring 1.0.2 and the integration with NHibernate. The Dao object here all extend from HibernateSupportDao
When I use the following xml configuration, I get an NHibernate Exception specifyin that it could not find the connection string setting.
<objects xmlns="http://www.springframework.net">
<object id="NVNInsuranceProductDatabasePublisher" parent="InsuranceProductDatabasePublisher">
<property name="ValidLanguages" value="nl-NL"/>
<property name="InsuranceDao.SessionFactory.DbProvider" ref="ProductDatabaseNVNDbProvider"/>
</object>
<object id="NVBInsuranceProductDatabasePublisher" parent="InsuranceProductDatabasePublisher">
<property name="ValidLanguages" value="nl-BE, fr-BE"/>
<property name="InsuranceDao.SessionFactory.DbProvider" ref="ProductDatabaseNVBDbProvider" />
</object>
<object id="InsuranceProductDatabasePublisher" type="ThomasCook.Ecom.ProductDatabase.Publish.Publishers .Insurances.ProductDatabaseInsurancePublisher, ThomasCook.Ecom.ProductDatabase" abstract="true">
<property name="LanguagePropertyExpression" value="Language"/>
<property name="InsuranceDao">
<object type="ThomasCook.Ecom.ProductDatabase.Publish.Dao.Implem entations.InsuranceDao, ThomasCook.Ecom.ProductDatabase">
<property name="SessionFactory">
<object parent="ProductDatabaseSessionFactory"/>
</property>
</object>
</property>
</object>
<object id="ProductDatabaseSessionFactory" type="Spring.Data.Orm.NHibernate.LocalSessionFactoryObje ct, Spring.Data.Orm.NHibernate" abstract="true" >
<property name="DbProvider">
<null/>
</property>
<!--Must be overridden by all concretes -->
<property name="MappingAssemblies">
<list>
<value>ThomasCook.Ecom.ProductDatabase</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<entry key="hibernate.show_sql" value="false" />
</dictionary>
</property>
</object>
<object id="ProductDatabaseNVBDbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${connection.NVBProductDatabaseDb}" />
</object>
<object id="ProductDatabaseNVNDbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${connection.NVNProductDatabaseDb}" />
</object>
</objects>
When I change the definition of the definition of the ProductDatabaseSessionFactory object not to include a null for the DbProvider property but a filled in value (eg a ref to ProductDatabaseNVNDbProvider), then I get an InvalidPropertyException "DbProvider" node can not be resolved for the specified root context.
Maybe this is something specific for the NHibertnate integration, since I have used this same setup in other places without any problem.
What are my alternatives here.
KR
Patrick