Hi,
I'm using Hibernate 3.2, Hibernate Annotations 3.2 CR1 & Spring 2.0 rc3. I have Entities across multiple datasource and relations between these entities.
Here is my Spring config file:
Code:
<bean id="mySqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://host/db"/>
<property name="username" value="******"/>
<property name="password" value="******"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="mySqlDataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>com.inno.staffing.model.entity.Competency</value>
<value>com.inno.staffing.model.entity.Experience</value>
<value>com.inno.staffing.model.entity.Customer</value>
<value>com.inno.staffing.model.entity.Project</value>
<value>com.inno.staffing.model.entity.Staffing</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
</props>
</property>
</bean>
<!--
Data Source for the Replicon Database
-->
<bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://host/db"/>
<property name="username" value="*****"/>
<property name="password" value="******"/>
</bean>
<bean id="repliconSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="sqlServerDataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>com.inno.staffing.model.entity.replicon.UserInfo</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName">
<value>java:/TransactionManager</value>
</property>
<property name="userTransactionName">
<value>UserTransaction</value>
</property>
</bean>
<!--
This bean is a post-processor that will automatically apply relevant advisors
to any bean in child factories.
-->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<!--
AOP advisor that will provide declarative transaction management based on
attributes. It's possible to add arbitrary custom Advisor implementations
as well, and they will also be evaluated and applied automatically.
-->
<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
<constructor-arg>
<ref local="transactionInterceptor"/>
</constructor-arg>
</bean>
<!--
Transaction interceptor to use for auto-proxy creation.
Transaction attributes will be read in from JDK 1.5+ annotations.
-->
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
</property>
</bean>
I'm trying to deploy on JBoss 4.0.4.GA, and i'm getting the following error
Code:
09:39:00,835 INFO [STDOUT] 09:39:00,835 ERROR [[/Staffing]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-persistence.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.inno.staffing.model.entity.Experience.consultant references an unknown entity: com.inno.staffing.model.entity.replicon.UserInfo
Caused by:
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.inno.staffing.model.entity.Experience.consultant references an unknown entity: com.inno.staffing.model.entity.replicon.UserInfo
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:288)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1205)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:901)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:827)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:957)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:924)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:415)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:155)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:297)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
...
Can someone help me with this?
Thanks.