自己也沒怎么搭建過框架,更何況還是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方法 }