I face the same problem:
In my user POJO, I have:
@ManyToOne
public Club getClub()
{
return club;
}
in my club POJO, I have:
@OneToMany(mappedBy = "club")
public Set<User> getUsers()
{
return users;
}
Here is my hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<mapping class="org.appfuse.model.User"/>
<mapping class="org.appfuse.model.Role"/>
<mapping class="com.clubber.model.Club"/>
<mapping class="com.clubber.model.Facility"/>
</session-factory>
</hibernate-configuration>
Here is my
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- Add new DAOs here -->
<bean id="clubDao" class="com.clubber.dao.hibernate.ClubDaoHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="facilityDao"
class="com.clubber.dao.hibernate.FacilityDaoHibernate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Add new Managers here -->
<bean id="clubManager" class="com.clubber.service.impl.ClubManagerImpl">
<constructor-arg ref="clubDao"/>
</bean>
<bean id="facilityManager"
class="com.clubber.service.impl.FacilityManagerImpl">
<constructor-arg ref="facilityDao"/>
</bean>
<!-- Add new Actions here -->
<bean id="clubAction" class="com.clubber.webapp.action.ClubAction"
scope="prototype">
<property name="clubManager" ref="clubManager"/>
</bean>
<bean id="facilityAction"
class="com.clubber.webapp.action.FacilityAction" scope="prototype">
<property name="facilityManager" ref="facilityManager"/>
</bean>
<bean class="org.appfuse.dao.spring.HibernateExtensionPostProcessor">
<property name="annotatedClasses">
<list>
<value>com.clubber.model.Club</value>
<value>com.clubber.model.Facility</value>
</list>
</property>
</bean>
</beans>
But I still encounter the following error, what's the fix for this ??
Running org.appfuse.webapp.listener.StartupListenerTest
ERROR - ContextLoader.initWebApplicationContext(203) | Context
initialization fa
iled
org.springframework.beans.factory.BeanCreationException: Error creating bean
wit
h name 'sessionFactory' defined in URL
[file:/D:/source/clubber/target/classes/a
pplicationContext-dao.xml]: Invocation of init method failed; nested
exception i
s org.hibernate.AnnotationException: @OneToOne or @ManyToOne on
org.appfuse.mode
l.User.club references an unknown entity: com.clubber.model.Club
Caused by:
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on
org.appfuse.model.
User.club references an unknown entity: com.clubber.model.Club
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:56)
at
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(
AnnotationConfiguration.java:428)
at
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Annotatio
nConfiguration.java:286)
at
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1283)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:805)
at
org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:745)
at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:134)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:428)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:251)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:248)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:160)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:284)
at
org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:352)
at
org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:244)
at
org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:187)
at
org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:49)
at
org.appfuse.webapp.listener.StartupListenerTest.setUp(StartupListener
Test.java:39)
at junit.framework.TestCase.runBare(TestCase.java:128)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.jav
a:210)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes
tSet(AbstractDirectoryTestSuite.java:135)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Ab
stractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
refireBooter.java:225)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
ava:747)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.14 sec <<<
FAI
LURE!
Running org.appfuse.service.UserSecurityAdviceTest
DEBUG - UserSecurityAdvice.before(59) | Verifying that 'user' can modify
'admin'
WARN - UserSecurityAdvice.before(62) | Access Denied: 'user' tried to modify
'ad
min'!
WARN - UserSecurityAdvice.before(94) | Access Denied: 'user' tried to change
the
ir role(s)!
WARN - UserSecurityAdvice.before(94) | Access Denied: 'user' tried to change
the
ir role(s)!
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.219 sec
Results :
Tests run: 82, Failures: 0, Errors: 10, Skipped: 0
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] There are test failures.
[INFO]
------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 32 seconds
[INFO] Finished at: Mon Jun 25 22:34:59 SGT 2007
[INFO] Final Memory: 15M/27M
[INFO]
------------------------------------------------------------------------
ros wrote:
>
> Right. Thanks Matt!
>
--
View this message in context:
http://www.nabble.com/override-User-code-class-and-link-OneToMany-to-any-other-class-tf3217084s2369.html#a11288106
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]