-> 覆写方法
-> 启动项目失败,并报错:(省略具体信息)
Caused by: java.lang.reflect.InvocationTargetException: null
Caused by: org.hibernate.PropertyNotFoundException: Could not locate setter method for property [pdemoxlxm.domain.Bm#recordName]
-> 解决:贴注解@javax.persistence.Transient
启动时,不再报错
End...
-> 查了一下API
javax.persistence
Annotation Type Transient
@Target(value={METHOD,FIELD}) @Retention(value=RUNTIME) public @interface Transient
This annotation specifies that the property or field is not persistent. It is used to annotate a property or field of an entity class, mapped superclass, or embeddable class.
Example: @Entity public class Employee { @Id int id; @Transient User currentUser; ... }
Since:
Java Persistence 1.0
大体意思就是,注解@javax.persistence.Transient
在这样一种情况下使用,就是,使用了实体类中不存在字段(通常是多对一、一对多这种关系时),找不到该字段,运行时马上报错,使用该注解,是过度作用。