9 Replies Latest reply on Mar 26, 2007 11:56 AM by gavin.king

    Illegal use of mappedBy on both sides of the relationship: m

    irvega

      I have used seam-gen's generate-entities on a simple schema I knocked up (using HSQLDB), whilst I learn the basics of SEAM, with a view to prototype a system that will run against a legacy database.
      There is a many-to-many relationship between 2 tables A (the auto-generated PK is ID_) and B (the auto-generated PK is ID_) which is resolved by C which just holds the ids of A and B (as A_ID and B_ID, both columns constrained by foreign key constraints on tables A and B repectively). The schema is included below.
      The generated entity A has a Set of Bs and the generated entity for B has a Set of As. All good.

      When I deploy the app, using the generated ant script, I get

      Illegal use of mappedBy on both sides of the relationship: m2m.B.as

      (where the "as" in "B.as" is the plural of a).

      There's probably something going on under the covers as I can't see anything obvious in the generated source code (see below), possibly to do with cascading deletes (?). Is this a known condition of the reverse-engineering process for many to many relationships (possibly in Hibernate rather than seam-gen)? Is there some setting that needs to be set to avoid this?


      The schema looks like this
      CREATE MEMORY TABLE A(ID_ BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY)
      CREATE MEMORY TABLE B(ID_ BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY)
      CREATE MEMORY TABLE C(A_ID BIGINT NOT NULL,B_ID BIGINT NOT NULL,CONSTRAINT C_PK PRIMARY KEY(A_ID,B_ID),CONSTRAINT C_TO_A FOREIGN KEY(A_ID) REFERENCES A(ID_),CONSTRAINT C_TO_B FOREIGN KEY(B_ID) REFERENCES B(ID_))
      




      The generated java source code:

      A.java

      package m2m;
      // Generated 25-Mar-2007 18:15:55 by Hibernate Tools 3.2.0.b9
      
      import java.util.HashSet;
      import java.util.Set;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.Id;
      import javax.persistence.ManyToMany;
      import javax.persistence.Table;
      import org.hibernate.validator.NotNull;
      
      /**
       * A generated by hbm2java
       */
      @Entity
      @Table(name = "A", schema = "PUBLIC")
      public class A implements java.io.Serializable {
      
       private long id;
       private Set<B> bs = new HashSet<B>(0);
      
       public A() {
       }
      
       public A(long id) {
       this.id = id;
       }
       public A(long id, Set<B> bs) {
       this.id = id;
       this.bs = bs;
       }
      
       @Id
       @Column(name = "ID_", unique = true, nullable = false)
       @NotNull
       public long getId() {
       return this.id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
       @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "as")
       public Set<B> getBs() {
       return this.bs;
       }
      
       public void setBs(Set<B> bs) {
       this.bs = bs;
       }
      
      }
      



      B.java

      
      package m2m;
      // Generated 25-Mar-2007 18:15:55 by Hibernate Tools 3.2.0.b9
      
      import java.util.HashSet;
      import java.util.Set;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.Id;
      import javax.persistence.ManyToMany;
      import javax.persistence.Table;
      import org.hibernate.validator.NotNull;
      
      /**
       * B generated by hbm2java
       */
      @Entity
      @Table(name = "B", schema = "PUBLIC")
      public class B implements java.io.Serializable {
      
       private long id;
       private Set<A> as = new HashSet<A>(0);
      
       public B() {
       }
      
       public B(long id) {
       this.id = id;
       }
       public B(long id, Set<A> as) {
       this.id = id;
       this.as = as;
       }
      
       @Id
       @Column(name = "ID_", unique = true, nullable = false)
       @NotNull
       public long getId() {
       return this.id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
       @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "bs")
       public Set<A> getAs() {
       return this.as;
       }
      
       public void setAs(Set<A> as) {
       this.as = as;
       }
      
      }
      


        • 1. Re: Illegal use of mappedBy on both sides of the relationshi

          The @ManyToMany definition on one of the sides is incorrect. For bidirectional relationships one side must be the owner. The side using "mappedBy" is the inverse side, which means it updating it does NOT update the relationship.

          If this was generated it's probably a seam gen bug. To fix your generate objects you'll need to do the following to ONE of the @ManyToMany's.

          1) Remove the mappedBy attribute
          2) Add a @JoinTable

          So updating A to be the owner side does this. B would be unchanged. If you want B to be the owner side do the same but swap A_ID and B_ID round in the joinColumns/inverseJoinColumns attributes.

          @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
          @JoinTable(
           name="C",
           joinColumns={@JoinColumn(name="A_ID")},
           inverseJoinColumns={@JoinColumn(name="B_ID")}
           )
          


          Submit a bug report JIRA and I'm sure something will fix it, although guessing the owner side will be fun.

          HTH.

          Mike.

          • 2. Re: Illegal use of mappedBy on both sides of the relationshi
            irvega

            javax.faces.el.PropertyNotFoundException: Bean: q.BHome$$EnhancerByCGLIB$$fe5689a5, property: bId


            I appreciate the detailed response, thanks Mike.
            I have tried that and it certainly gets me past the deployment stage.
            Now I can go to the "B List" and to the "A List" pages and "Search" works but, when I try to create an A (I am asked me to login as usual/default on the first write access to the database action with any seam-gen generated apps) and then ... the Exception stack-trace below (fsd is the userid I entered).


            2007-03-25 22:34:40,187 INFO [q.Authenticator] authenticating fsd
            2007-03-25 22:34:40,453 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
            2007-03-25 22:34:40,453 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
            2007-03-25 22:34:40,468 DEBUG [org.ajax4jsf.framework.renderer.AjaxPhaseListener] Process after phase INVOKE_APPLICATION(5)
            2007-03-25 22:34:40,468 ERROR [org.jboss.seam.web.ExceptionFilter] uncaught exception
            javax.servlet.ServletException: Error calling action method of component with id login:_id30
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
             at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            2007-03-25 22:34:40,593 ERROR [org.jboss.seam.web.ExceptionFilter] exception root cause
            javax.faces.FacesException: Error calling action method of component with id login:_id30
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
             at javax.faces.component.UICommand.broadcast(UICommand.java:106)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:405)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
             at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            Caused by: javax.faces.el.EvaluationException: /login.xhtml @34,72 action="#{identity.login}": javax.faces.el.EvaluationException: Exception while invoking expression #{redirect.returnToCapturedView}
             at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
             ... 41 more
            Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{redirect.returnToCapturedView}
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
             at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
             at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
             at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:106)
             at org.jboss.seam.core.Events.raiseEvent(Events.java:63)
             at org.jboss.seam.security.Identity.postAuthenticate(Identity.java:289)
             at org.jboss.seam.security.RuleBasedIdentity.postAuthenticate(RuleBasedIdentity.java:70)
             at org.jboss.seam.security.Identity.authenticate(Identity.java:250)
             at org.jboss.seam.security.Identity.authenticate(Identity.java:242)
             at org.jboss.seam.security.Identity.login(Identity.java:172)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
             at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
             at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
             at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
             ... 42 more
            Caused by: javax.faces.el.PropertyNotFoundException: Bean: q.BHome$$EnhancerByCGLIB$$fe5689a5, property: bId
             at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:483)
             at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:454)
             at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:417)
             at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
             at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
             at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
             at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
             at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:57)
             at org.jboss.seam.pages.Param.getValueFromModel(Param.java:93)
             at org.jboss.seam.core.Pages.getPageParameterValue(Pages.java:582)
             at org.jboss.seam.core.Pages.getConvertedParameters(Pages.java:558)
             at org.jboss.seam.core.Pages.encodePageParameters(Pages.java:692)
             at org.jboss.seam.core.Manager.redirect(Manager.java:973)
             at org.jboss.seam.core.Redirect.execute(Redirect.java:137)
             at org.jboss.seam.core.Redirect.returnToCapturedView(Redirect.java:154)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
             ... 59 more
            2007-03-25 22:34:40,984 INFO [org.jboss.seam.core.Exceptions] reading exception mappings from /WEB-INF/pages.xml
            2007-03-25 22:34:41,000 ERROR [org.jboss.seam.exceptions.DebugPageHandler] redirecting to debug page
            javax.faces.el.PropertyNotFoundException: Bean: q.BHome$$EnhancerByCGLIB$$fe5689a5, property: bId
             at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:483)
             at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:454)
             at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:417)
             at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
             at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
             at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
             at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
             at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:57)
             at org.jboss.seam.pages.Param.getValueFromModel(Param.java:93)
             at org.jboss.seam.core.Pages.getPageParameterValue(Pages.java:582)
             at org.jboss.seam.core.Pages.getConvertedParameters(Pages.java:558)
             at org.jboss.seam.core.Pages.encodePageParameters(Pages.java:692)
             at org.jboss.seam.core.Manager.redirect(Manager.java:973)
             at org.jboss.seam.core.Redirect.execute(Redirect.java:137)
             at org.jboss.seam.core.Redirect.returnToCapturedView(Redirect.java:154)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
             at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
             at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
             at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:106)
             at org.jboss.seam.core.Events.raiseEvent(Events.java:63)
             at org.jboss.seam.security.Identity.postAuthenticate(Identity.java:289)
             at org.jboss.seam.security.RuleBasedIdentity.postAuthenticate(RuleBasedIdentity.java:70)
             at org.jboss.seam.security.Identity.authenticate(Identity.java:250)
             at org.jboss.seam.security.Identity.authenticate(Identity.java:242)
             at org.jboss.seam.security.Identity.login(Identity.java:172)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
             at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
             at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
             at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)
             at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
             at javax.faces.component.UICommand.broadcast(UICommand.java:106)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
             at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:405)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
             at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
             at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            
            


            • 3. Re: Illegal use of mappedBy on both sides of the relationshi

              I can't see a bId property defined anywhere in the B entity? Or is it on BHome?

              • 4. Re: Illegal use of mappedBy on both sides of the relationshi
                irvega

                It's probaby on BHome (that's where the code generation created it).

                public class BHome extends EntityHome<B> {
                
                 public void setBId(Long id) {
                 setId(id);
                 }
                ...
                



                The exception says

                "Bean: q.BHome$$EnhancerByCGLIB$$fe5689a5, property: bId"






                • 5. Re: Illegal use of mappedBy on both sides of the relationshi
                  maxandersen

                  known bug with many-to-many reveengineering and annotations. (issue is that it does not really have info to choose which side should "win")

                  • 6. Re: Illegal use of mappedBy on both sides of the relationshi
                    irvega

                    Is there a suggested workaround? Is there a fix coming?

                    • 7. Re: Illegal use of mappedBy on both sides of the relationshi
                      maxandersen

                      workarounds:
                      1) don't enable many-to-many detection (see hibernate tools doc for how)
                      2) hand edit the associations to choose who "wins"

                      for a fix we just need to come up with a "deterministic and works-ok" solution for choosing the default "winner". Suggestions welcome ;)

                      • 8. Re: Illegal use of mappedBy on both sides of the relationshi
                        irvega

                        If you have a spare moment, could you please give a specific example of how I can do as you suggest using SEAM and, in particular, seam-gen?

                        On Michael Yuan's website there is a link to a video where in a 5 min he generates an app with seam-gen (via Eclipse). The intro text on the site says this includes a many to many relationship in the schema. Is this possible?

                        • 9. Re: Illegal use of mappedBy on both sides of the relationshi
                          gavin.king

                          Max, I would prefer if many-to-many detection was disabled OOTB with seam-gen.