Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 休眠枚举集错误_Java_Hibernate_Enums_Enumset - Fatal编程技术网

Java 休眠枚举集错误

Java 休眠枚举集错误,java,hibernate,enums,enumset,Java,Hibernate,Enums,Enumset,我有一个角色对象,它拥有多个权限(即ENUM)。 但我一直在犯这个错误 Use of @OneToMany or @ManyToMany targeting an unmapped class: objects.Role.permissions[enums.AgentPermission] 最好的表达方式是什么 角色类别: @Entity @Table(name="\"Role\"") public class Role { @Id @GeneratedValue pr

我有一个角色对象,它拥有多个权限(即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;
    }
    ....
}
@实体
@表(名称=“\”角色\”)
公共阶级角色{
@身份证
@生成值
私有int-id;
@许多酮
私营公司;
私有字符串名称;
@许多
私有设置权限;
公共int getId(){
返回id;
}
公共无效集合id(内部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>

com.mysql.jdbc.Driver
org.hibernate.dialogue.mysql5innodbdialogue
....    
....    

在您的权限集上尝试@ElementCollection