-->
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.  [ 1 post ] 
Author Message
 Post subject: Many-to-Many
PostPosted: Tue May 02, 2006 3:43 am 
Newbie

Joined: Sat Feb 26, 2005 11:45 am
Posts: 13
Location: Stockholm, Sweden
Have seen questions about many-to-many mappings on the forum but not any pure example.

Im trying to do an many-to-many implementation of user-authority to be able to use acegi.

My user-class have these annotation
@Entity
@Table(name = "SALESTOOLUSER")
public class SalesToolUser implements UserDetails, Serializable {
@Id @GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
public String getId() {
return id;
}

@ManyToMany(
targetEntity=com.tele2.salestool.domain.Authority.class,
cascade={CascadeType.ALL})
@JoinTable(
name="USER_AUTHORITY",
joinColumns={@JoinColumn(name="userid")},
inverseJoinColumns={@JoinColumn(name="authorityid")})
@IndexColumn(name = "authority_position", base=0)
public GrantedAuthority[] getAuthorities() {
return this.authorities;
}
.............
}

My authority-class looks like this
@Entity
@Table (name="AUTHORITY")
public class Authority implements Serializable{
@Id @GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
public String getId() {
return id;
}
@ManyToMany(
cascade={CascadeType.PERSIST, CascadeType.MERGE},
mappedBy="authorities",
targetEntity=SalesToolUser.class
)
@IndexColumn(name = "salesToolUser_position", base=0)
public SalesToolUser[] getSalesToolUsers(){
return this.salesToolUsers;
}
..............
}

I have a table in the database but no pojo called user_authority.

I really don't have a clue why I get this errormessage, I have annotated with IndexColumn... In the examples the methods return a Set or Collection. The acegi does not implement it this way and I can't really see this as a problem.

Please could anyone guide me in the right direction ?!!


Hibernate version:3.2.0cr1
Hibernate annotation:3.1beta9

Full stack trace of any exception that occurs:
ERROR - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/fenix-data.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: List/array has to be annotated with an @IndexColumn: com.tele2.salestool.domain.SalesToolUser.authorities
org.hibernate.AnnotationException: List/array has to be annotated with an @IndexColumn: com.tele2.salestool.domain.SalesToolUser.authorities
at org.hibernate.cfg.annotations.ListBinder.bindIndex(ListBinder.java:109)
at org.hibernate.cfg.annotations.ListBinder.access$000(ListBinder.java:35)
at org.hibernate.cfg.annotations.ListBinder$1.secondPass(ListBinder.java:70)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1016)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:244)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:811)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:737)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:856)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:825)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:418)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:241)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:152)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:247)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:331)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:155)
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)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:804)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:693)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1118)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1020)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
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.catalina.startup.Bootstrap.start(Bootstrap.java:275)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Name and version of the database you are using:mysql 5


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

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.