-->
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.  [ 3 posts ] 
Author Message
 Post subject: Repeated column in mapping for collection
PostPosted: Sat Dec 05, 2009 8:36 pm 
Newbie

Joined: Sat Dec 05, 2009 8:08 pm
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Repeated column in mapping for collection
PostPosted: Thu Dec 10, 2009 8:08 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Use Eclipse Hibernate plugins for mappings - they help much.
You didn't provide Role class mapping, I guess the problem there. You should have something like this:

@Entity
@Table(name = "QF_Role")
public class Role implements Serializable {
......
@ManyToMany(mappedBy = "roles")
private Set<User> users;
}


Top
 Profile  
 
 Post subject: Repeated column in mapping for collection
PostPosted: Thu Feb 25, 2010 2:41 am 
Newbie

Joined: Sat Dec 05, 2009 8:08 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.