-->
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: @ManyToMany - Could not determine type for: java.util.Set
PostPosted: Thu Jul 02, 2009 11:01 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
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.


Top
 Profile  
 
 Post subject: Re: @ManyToMany - Could not determine type for: java.util.Set
PostPosted: Fri Jul 03, 2009 2:54 am 
Regular
Regular

Joined: Sun Sep 30, 2007 7:51 pm
Posts: 93
Hm. I'm not sure, but you don't need to define the targetEntity if you have generics. Can't you use OneToMany with same effect?


Top
 Profile  
 
 Post subject: Re: @ManyToMany - Could not determine type for: java.util.Set
PostPosted: Fri Jul 03, 2009 8:34 am 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
I have actually been wondering that myself, regardless the ManyToMany should work (in my mind) as it does in other entities in my current setup.


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.