hibernate报错:MappingException: Could not determine type for...解决办法

有时候实体里的一些属性并不想映射到数据库(比方说子级菜单List),

如果不做处理的话会报字段映射错误找不到这列Column Not Found

例如:org.hibernate.MappingException: Could not determine type for: java.util.List, at table: xxxx, for columns: [org.hibernate.mapping.Column(xxx)]

Hibernate实体类注解可以让某些属性不映射到数据库

使用hibernate注解@Transien放在属性上即可解决此问题。

import javax.persistence.Transient;

没有get方法的属性可以直接写在属性上面,有get方法的要在get方法上也写上

import com.fasterxml.jackson.annotation.JsonIgnore;
@JsonIgnore
学习时的痛苦是暂时的 未学到的痛苦是终生的
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/juanxincai/p/12345977.html