I created a many to many relationship with an extra table(REFEREEFOUL) having the two primary keys of table foul and referee. I can add data to both tables but the extra table gets no values. how can I say that a record in foul table is related to a referee in the other table?
Relationship in Referee class:
@ManyToMany(mappedBy = "refereeList", fetch = FetchType.EAGER)
private List<Foul> foulList;
Relationship in Foul class:
@JoinTable(name = "REFEREEFOUL", joinColumns = {
@JoinColumn(name = "FOULID", referencedColumnName = "ID")}, inverseJoinColumns = {
@JoinColumn(name = "REFEREEID", referencedColumnName = "ID")})
@ManyToMany(fetch = FetchType.EAGER)
private List<Referee> refereeList;
the relationships are correct, I use PersistAction.Create for creating new fouls and referees. but the problem is that I cant link them
<h:panelGroup id="display">
<p:panelGrid columns="2" rendered="#{refereeController.selected != null}">
<p:outputLabel value="id" for="id" />
<p:inputText id="id" value="#{refereeController.selected.id}" />
<p:outputLabel refereename" for="refereename" />
<p:inputText id="refereename" value="#{refereeController.selected.refereename}" title="#{bundle.CreateRefereeTitle_refereename}" />
<p:outputLabel value="refereeposition" for="refereeposition" />
<p:inputText id="refereeposition" value="#{refereeController.selected.refereeposition}" />
<p:outputLabel value="gameid" for="gameid" />
<p:selectOneMenu id="gameid" value="#{refereeController.selected.gameid}" >
<f:selectItems value="#{gameController.itemsAvailableSelectOne}"
var="gameidItem"
itemValue="#{gameidItem}"/>
</p:selectOneMenu>
</p:panelGrid>
<p:commandButton actionListener="#{refereeController.create}" value="#{bundle.Save}" update="display,:RefereeListForm:datalist,:growl" oncomplete="handleSubmit(args,'RefereeCreateDialog');"/>
</h:panelGroup>