pablogore wrote:
Hibernate Version:3.2.5ga
data base:mysql 5
Hello everyone.
I have a problem when I tried to made manyToMany relation.
Table one QF_USER has the primary key with organizationName,userId
Table two QF_ROLE has the primary key with organizationName,roleId
In the entity User , I want to put a collection of Role when the user participated , I did something like this.
@Entity
@Table(name = "QF_USER")
public class User implements Serializable {
......
@ManyToMany(targetEntity=Role.class,fetch=FetchType.LAZY,cascade=CascadeType.ALL)
@JoinTable(name="QF_USER_ROLE",
joinColumns={@JoinColumn(name="userId"),@JoinColumn(name="organizationName")},
inverseJoinColumns={@JoinColumn(name="roleName"), @JoinColumn(name="organizationName")})
private Set<Role> roles;
}
Well , in My tomcat log I see the stack trace with this exception
[WARNING] [talledLocalContainer] INFO: Starting the HTTP client
[INFO] [talledLocalContainer] org.hibernate.MappingException: Repeated column in mapping for collection: com.quickflows.metadata.entities.User.roles column: organizationName
[INFO] [talledLocalContainer] at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:306)
[INFO] [talledLocalContainer] at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:329)
[INFO] [talledLocalContainer] at org.hibernate.mapping.Collection.validate(Collection.java:286)
[INFO] [talledLocalContainer] at org.hibernate.mapping.Set.validate(Set.java:19)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
[INFO] [talledLocalContainer] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
[INFO] [talledLocalContainer] at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
[INFO] [talledLocalContainer] at com.quickflows.metadata.HibernateUtil.<clinit>(HibernateUtil.java:34)
[INFO] [talledLocalContainer] at com.quickflows.server.QuickflowsFilter.beforeHandle(QuickflowsFilter.java:32)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:193)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
[INFO] [talledLocalContainer] at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:112)
[INFO] [talledLocalContainer] at org.restlet.Application.handle(Application.java:341)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at org.restlet.Router.handle(Router.java:504)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at org.restlet.Router.handle(Router.java:504)
[INFO] [talledLocalContainer] at org.restlet.Filter.doHandle(Filter.java:150)
[INFO] [talledLocalContainer] at org.restlet.Filter.handle(Filter.java:195)
[INFO] [talledLocalContainer] at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124)
[INFO] [talledLocalContainer] at org.restlet.Component.handle(Component.java:673)
[INFO] [talledLocalContainer] at org.restlet.Server.handle(Server.java:331)
[INFO] [talledLocalContainer] at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:68)
[INFO] [talledLocalContainer] at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:147)
[INFO] [talledLocalContainer] at com.noelios.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:881)
[INFO] [talledLocalContainer] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
[INFO] [talledLocalContainer] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[INFO] [talledLocalContainer] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:567)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[INFO] [talledLocalContainer] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
[INFO] [talledLocalContainer] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
[INFO] [talledLocalContainer] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
[INFO] [talledLocalContainer] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:619)
So , I need help with this.
thanks