2015-11-20 132 views
1

我有一個角色對象,它擁有多個權限(這是ENUM)。 但我不斷收到此錯誤。休眠枚舉設置錯誤

Use of @OneToMany or @ManyToMany targeting an unmapped class: objects.Role.permissions[enums.AgentPermission] 

什麼是表示的最佳方式。

角色類:

@Entity 
@Table(name="\"Role\"") 
public class Role { 
    @Id 
    @GeneratedValue 
    private int id; 
    @ManyToOne 
    private Company company; 
    private String name; 
    @ManyToMany 
    private Set<AgentPermission> permissions; 
    public int getId() { 
     return id; 
    } 
    public void setId(int id) { 
     this.id = id; 
    } 
    .... 
} 

的hibernate.cfg.xml

<?xml version='1.0' encoding='utf-8'?> 
<!DOCTYPE hibernate-configuration PUBLIC 
     "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
     "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> 

<hibernate-configuration> 
    <session-factory> 
     <!-- hibernate dialect --> 
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> 
....  
     <mapping class="objects.Role" /> 
     <mapping class="objects.Tag" /> 
....  
    </session-factory> 
</hibernate-configuration> 

回答

1

嘗試@ElementCollection您的權限。

+0

它的工作。謝謝 :) –