【问题标题】:Hibernate Enum Set Error休眠枚举集错误
【发布时间】:2015-11-20 22:25:39
【问题描述】:

我有一个 Role 对象,它拥有多个权限(即 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>

【问题讨论】:

    标签: java hibernate enums enumset


    【解决方案1】:

    在您的权限集上尝试 @ElementCollection。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 2012-01-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多