No identifier specified for entity: main.java.com.sy.entity.User
2015-12-16 22:15
423 查看
自己没怎么搭建过框架,更何况还是spring mvc的,最近在带两个实习生,正好教他们怎么搭建一个spring mvc的框架,然而我在映射表的时候,提示报错了。
实体基类:
User类:
查阅国外的论坛之后得出一个结论,自己好菜啊!解决办法特别简单!!!在实体基类上加一个@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方法 }
User类:
@Entity @Table(name="sys_user") public class User extends BaseEntity { private String loginName; private String userName; private String password; //get、set方法 }
查阅国外的论坛之后得出一个结论,自己好菜啊!解决办法特别简单!!!在实体基类上加一个@MappedSuperclass
<span style="color:#ff0000;">@MappedSuperclass</span> 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方法 }
相关文章推荐
- 深入分析JavaWeb Item24 -- jsp2.X自定义标签开发进阶
- java容器
- Java——new 接口
- 求助,eclipse总是卡在building workspace-CSDN论坛
- [javase学习笔记]-6.1 面向对象的概述
- 毕向东 35day java基础学习
- eclipse hibernate tool 报错 - Fetching children of Database
- Java--随机数和随机数种子(转)
- Struts2配置dtd约束
- 第三个spring冲刺第10天
- First Bad Version leetcode java
- java关键字
- KMP算法java实现
- java集合——视图与包装器
- 关于 spring 视图解析器
- 【算法拾遗(java描述)】--- 交换排序(冒泡、快排)
- Java与C之间的socket通信
- 【Struts2】从ActionContext中获取页面属性
- Java--重载与重写的区别
- 【Struts2】请求参数的接受