ok so im trying to created a self referencing many-to-many relationship
but I keep getting hte following error
org.hibernate.MappingException: Could not determine type for: java.util.Set, for columns: [org.hibernate.mapping.Column(portals)]
here is my entity
Code:
// Generated 14-May-2009 10:51:17 PM by Hibernate Tools 3.2.4.GA
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
/**
* Portal generated by hbm2java
*/
@Entity
@Table(name = "portal")
public class Portal implements java.io.Serializable {
private int portalId;
private int version;
private String portalName;
private Set<PortalLadder> portalLadders = new HashSet<PortalLadder>(0);
private Set<PortalAdmin> portalAdmins = new HashSet<PortalAdmin>(0);
private Set<Portal> portals = new HashSet<Portal>(0);
private Set<PortalLeague> portalLeagues = new HashSet<PortalLeague>(0);
public Portal() {
}
public Portal(int portalId, String portalName) {
this.portalId = portalId;
this.portalName = portalName;
}
public Portal(int portalId, String portalName,
Set<PortalLadder> portalLadders, Set<PortalAdmin> portalAdmins,
Set<PortalLeague> portalLeagues,
Set<Portal> portals
) {
this.portalId = portalId;
this.portalName = portalName;
this.portalLadders = portalLadders;
this.portalAdmins = portalAdmins;
this.portalLeagues = portalLeagues;
this.portals = portals;
}
@Id
@SequenceGenerator( name="PORTAL_SEQ_GEN", sequenceName="PORTAL_SEQ" )
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="PORTAL_SEQ_GEN" )
@Column(name = "portal_id", unique = true, nullable = false)
public int getPortalId() {
return this.portalId;
}
public void setPortalId(int portalId) {
this.portalId = portalId;
}
@Version
@Column(name = "version", nullable = false)
public int getVersion() {
return this.version;
}
public void setVersion(int version) {
this.version = version;
}
@Column(name = "portal_name", nullable = false, length = 45)
@NotNull
@Length(max = 45)
public String getPortalName() {
return this.portalName;
}
public void setPortalName(String portalName) {
this.portalName = portalName;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "portal")
public Set<PortalLadder> getPortalLadders() {
return this.portalLadders;
}
public void setPortalLadders(Set<PortalLadder> portalLadders) {
this.portalLadders = portalLadders;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "portal")
public Set<PortalAdmin> getPortalAdmins() {
return this.portalAdmins;
}
public void setPortalAdmins(Set<PortalAdmin> portalAdmins) {
this.portalAdmins = portalAdmins;
}
@ManyToMany( targetEntity = Portal.class )
@JoinTable(name="Portal_Group",
joinColumns=
@JoinColumn(name="Parent_Portal_Id"),
inverseJoinColumns=
@JoinColumn(name="Portal_Id" )
)
public void setPortals( Set<Portal> portals ){
this.portals = portals;
}
public Set<Portal> getPortals(){
return this.portals;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "portal")
public Set<PortalLeague> getPortalLeagues() {
return this.portalLeagues;
}
public void setPortalLeagues(Set<PortalLeague> portalLeagues) {
this.portalLeagues = portalLeagues;
}
}
and the relation table is as follows
Code:
Portal_Group
===============
parent_portal_id
portal_id
version
the only thing i can think of is that its a self referencing many-to-many
because I know it works for non-self referencing many-to-manys because I have 4 of them already working fine :\
also in the targetEntity I tried having hte fully qualified class name, but it didnt make a difference.