-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @OneToOne or @ManyToOne references an unknown entity
PostPosted: Wed Sep 13, 2006 4:13 am 
Newbie

Joined: Wed Sep 13, 2006 3:55 am
Posts: 1
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 9:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
having relation between entities in different persistence unit is not possible

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.