首页 > 编程语言 > 详细

报错:No identifier specified for entity: main.java.com.sy.entity.User的解决办法

时间:2015-12-15 22:43:49      阅读:399      评论:0      收藏:0      [点我收藏+]

自己也没怎么搭建过框架,更何况还是spring mvc的,最近在带两个实习生,正好教他们怎么搭建一个spring mvc的框架,然而我在映射表的时候,提示报错了。

 

实体基类:

public class BaseEntity implements Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    
    @Column(updatable=false)
    protected Date creatTime=new Date();
    
    @Column(updatable=false)
    protected String creatUser;
    
    @Column(insertable=false)
    protected Date updateTime=new Date();
    
    @Column(insertable=false)
    protected String updateUser;

    //get,set方法
}

 

User类:

@Entity
@Table(name="sys_user")
public class User extends BaseEntity {
    
    private String loginName;
    
    private String userName;
    
    private String password;
    
    //get、set方法
    
}

 

代码看了感觉没问题啊,查阅国外的论坛之后得出一个结论,自己好菜啊!解决办法特别简单!!!在实体基类上加一个@MappedSuperclass

@MappedSuperclass
public class BaseEntity implements Serializable{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected Long id;
    
    @Column(updatable=false)
    protected Date creatTime=new Date();
    
    @Column(updatable=false)
    protected String creatUser;
    
    @Column(insertable=false)
    protected Date updateTime=new Date();
    
    @Column(insertable=false)
    protected String updateUser;

    //get,set方法

}

报错:No identifier specified for entity: main.java.com.sy.entity.User的解决办法

原文:http://www.cnblogs.com/phil_jing/p/5049500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!