Spring 注解实体类中非数据库字段属性

今天要给一个实体类添加一个List集合属性!

private List<Reverts> childList = new ArrayList<Reverts>();

写完后get/set方法一写,启动就报错:

org.hibernate.MappingException: Could not determine type for: java.util.List, at table: T_REVERTS, for columns: [org.hibernate.mapping.Column(childList)]

解决办法:在属性的get方法上加上一段注解标识它是临时属性,不是数据库字段就OK

@Transient 
	public List<Reverts> getChildList() {
		return childList;
	}
	public void setChildList(List<Reverts> childList) {
		this.childList = childList;
	}

记得导入的是: import javax.persistence.Transient;






你可能感兴趣的:(Spring 注解实体类中非数据库字段属性)