当使用 @MappedSuperclass,@Entity,@ManyToMany 报:Could not determine type for-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

当使用 @MappedSuperclass,@Entity,@ManyToMany 报:Could not determine type for

2016-03-16 18:12:08 3315 1
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: com.rootls] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:286)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 50 more
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set, at table: user, for columns: [org.hibernate.mapping.Column(roles)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:305)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:289)
at org.hibernate.mapping.Property.isValid(Property.java:238)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:468)
at org.hibernate.mapping.RootClass.validate(RootClass.java:270)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1294)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1736)
at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 56 more
@MappedSuperclass
public abstract class IdEntity /*extends AbstractPersistable<Integer>*/
        implements Serializable,Cloneable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Integer id;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.setId(id);
    }
}

@Entity
@Table(name = "user")
//@AttributeOverride( name="id", column = @Column(name="id") )
public class User extends IdEntity{

    @ManyToMany
    @JoinTable(name = "user_role",
            joinColumns = @JoinColumn(name = "user_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
    public Set<Role> getRoles() {
        return roles;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }

@Entity
@Table(name = "role")
//@AttributeOverride( name="id", column = @Column(name="id") )
public class Role extends IdEntity {

    private Set<User> users = new HashSet<User>();

    @ManyToMany(mappedBy = "roles")
    public Set<User> getUsers() {
        return users;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }
项目地址:https://github.com/luowei/mvn-test
sql脚本:
 create table user(
      id int(11) primary key auto_increment,
      username varchar(100) not null,
      password varchar(92) not null,
      email varchar(50)
    );

    create table role(
      id int(11) primary key auto_increment,
      role_name varchar(30) not null,
      role_description varchar(100),
      create_time timestamp not null

    );

    create table user_role(
      id int(11) primary key auto_increment,
      user_id int(11) not null,
      role_id int(11) not null,

      constraint uq_user_role unique(user_id, role_id)
    );
SQL
取消 提交回答
全部回答(1)
  • 游客kbg3zx67ykxdy
    2020-03-30 19:57:00

    注解要么全在属性上,要么全在getter上,混合就会报“Could not determine type for”

    0 0
相关问答

0

回答

请问大家使用 flink-cdc-postgres 有遇到下面的问题吗? cannot execut

2022-07-05 18:21:38 260浏览量 回答数 0

1

回答

明明安卓终端已经装了最新版本的chrome浏览器了,为什么还一直提示请使用最新版本的chrome?

2020-12-23 14:25:53 1776浏览量 回答数 1

2

回答

串口摄像头是否可以通过MQTT协议传JPG图片(800*600)到阿里云物联网平台?

2020-10-07 07:03:16 1544浏览量 回答数 2

1

回答

遇到 Not a valid expression format type 怎么解决?c报错

2020-05-29 10:59:33 326浏览量 回答数 1

2

回答

使用了阿里云CDN后首页缓存命中率为什么一直MISS

2019-06-28 01:41:31 5322浏览量 回答数 2

1

回答

MiniProgramStudio.exe 同时支持开发微信小程序这一端么?

2019-04-12 11:32:22 2693浏览量 回答数 1

2

回答

使用js上传base64 图片上传

2018-09-06 16:43:47 657浏览量 回答数 2

1

回答

postgres 9.6版本,data type uuid has no default operator class for access methodgin

2017-11-17 19:59:50 3508浏览量 回答数 1

1

回答

JSP页面关于foreach的使用?

2016-06-14 15:22:15 2129浏览量 回答数 1

2

回答

阿里云社区发帖页面,上传图片和获取验证码不兼容chrome浏览器

2012-09-29 20:21:25 5805浏览量 回答数 2
文章
问答
问答排行榜
最热
最新
相关电子书
更多
Semantic Search--Fast Results from Large,Foreign Language Corpora
立即下载
Why you should care about data layout in the file system
立即下载
Needle in the Haystack—User Behavior Anomaly Detection for Information Security
立即下载