title: You must define at least one mapping for this table
body: <p><strong>THIS QUESTION IS CLOSED</strong></p>
  
  <p>I'm trying to make a application that will send a messages. when i create new message i have to create to conversation table to differentiate the conversation of user A, B, C. then create conversation_member to insert all the receivers of the message then insert the message content and the sender in the message table. ahm try to check the ERD to clarify things... sorry not good in explain things </p>
  
  <p>Thanks .. really need help here ... </p>
  
  <p><strong>ENTITY Conversation</strong></p>
  
  <pre><code>@Entity
  @Table(name = "conversation")
  @XmlRootElement
  @NamedQueries({
  @NamedQuery(name = "Conversation.findAll", query = "SELECT c FROM Conversation c"),
  @NamedQuery(name = "Conversation.findById", query = "SELECT c FROM Conversation c WHERE c.id = :id")})
  
  public class Conversation implements Serializable {
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "conversationId")
  private Collection&lt;Message&gt; messageCollection;
  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Basic(optional = false)
  @Column(name = "id")
  private Integer id;
  @JoinTable(name = "conversation_member", joinColumns = {
      @JoinColumn(name = "conversation_id", referencedColumnName = "id")}, inverseJoinColumns = {
      @JoinColumn(name = "user_id", referencedColumnName = "user_id")})
  @ManyToMany
  private Collection&lt;User&gt; userCollection;
  
  public Conversation() {
  }
  
  public Conversation(Integer id) {
      this.id = id;
  }
  
  public Integer getId() {
      return id;
  }
  
  public void setId(Integer id) {
      this.id = id;
  }
  
  @XmlTransient
  public Collection&lt;User&gt; getUserCollection() {
      return userCollection;
  }
  
  public void setUserCollection(Collection&lt;User&gt; userCollection) {
      this.userCollection = userCollection;
  }
  
  @Override
  public int hashCode() {
      int hash = 0;
      hash += (id != null ? id.hashCode() : 0);
      return hash;
  }
  
  @Override
  public boolean equals(Object object) {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Conversation)) {
          return false;
      }
      Conversation other = (Conversation) object;
      if ((this.id == null &amp;&amp; other.id != null) || (this.id != null &amp;&amp; !this.id.equals(other.id))) {
          return false;
      }
      return true;
  }
  
  @Override
  public String toString() {
      return "" + id ;
  }
  
  @XmlTransient
  public Collection&lt;Message&gt; getMessageCollection() {
      return messageCollection;
  }
  
  public void setMessageCollection(Collection&lt;Message&gt; messageCollection) {
      this.messageCollection = messageCollection;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>ConversationController</strong></p>
  
  <pre><code> public void create() {
      try {
  
          getFacade().create(current);
  
      } catch (Exception e) {
          System.out.println(e);
      }
  }
  </code></pre>
  
  <p><strong>ERD</strong></p>
  
  <p><img src="https://i.stack.imgur.com/hLXMi.png" alt="enter image description here"></p>
  
  <p><strong>Glassfish 3.1.2</strong></p>
  
  <pre><code>    WARNING: Local Exception Stack: 
      Exception [EclipseLink-6023] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.QueryException
      Exception Description: The list of fields to insert into the table [DatabaseTable(conversation)] is empty.  You must define at least one mapping for this table.
  at org.eclipse.persistence.exceptions.QueryException.objectToInsertIsEmpty(QueryException.java:935)
  at org.eclipse.persistence.internal.expressions.SQLInsertStatement.buildCallWithoutReturning(SQLInsertStatement.java:59)
  at org.eclipse.persistence.internal.expressions.SQLModifyStatement.buildCall(SQLModifyStatement.java:61)
  at org.eclipse.persistence.descriptors.ClassDescriptor.buildCallFromStatement(ClassDescriptor.java:740)
  at org.eclipse.persistence.internal.queries.StatementQueryMechanism.setCallFromStatement(StatementQueryMechanism.java:387)
  at org.eclipse.persistence.internal.queries.StatementQueryMechanism.prepareInsertObject(StatementQueryMechanism.java:301)
  at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.prepareInsertObject(ExpressionQueryMechanism.java:1583)
  at org.eclipse.persistence.queries.InsertObjectQuery.prepare(InsertObjectQuery.java:109)
  at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:613)
  at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:575)
  at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:216)
  at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:123)
  at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3799)
  at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1415)
  at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:636)
  at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkImpl.java:1561)
  at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.writeChanges(RepeatableWriteUnitOfWork.java:447)
  at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:780)
  at com.sun.enterprise.container.common.impl.EntityManagerWrapper.flush(EntityManagerWrapper.java:418)
  at biz.dtit.golf.entities.AbstractFacade.create(AbstractFacade.java:29)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
  at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
  at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
  at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
  at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
  at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
  at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
  at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
  at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
  at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
  at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
  at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
  at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
  at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
  at $Proxy149.create(Unknown Source)
  at biz.dtit.golf.entities.__EJB31_Generated__ConversationFacade__Intf____Bean__.create(Unknown Source)
  at biz.dtit.golf.entities.ConversationController.create(ConversationController.java:83)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779)
  at javax.el.BeanELResolver.invoke(BeanELResolver.java:528)
  at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)
  at com.sun.el.parser.AstValue.invoke(AstValue.java:248)
  at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
  at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
  at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
  at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
  at javax.faces.component.UICommand.broadcast(UICommand.java:315)
  at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
  at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
  at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
  at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  at SessionFilter.doFilter(SessionFilter.java:41)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  at NoCacheFilter.doFilter(NoCacheFilter.java:41)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
  at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
  at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
  at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
  at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
  at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
  at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
  at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
  at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
  at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
  at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
  at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
  at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
  at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
  at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
  at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
  at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
  at java.lang.Thread.run(Thread.java:722)
  </code></pre>