Could not determine type for: org.springframework.web.multipart.MultipartFile, at table: CMRI_REPORT, for columns: [org.hibernate.mapping.Column(reportFile)]
根据报错信息显示这里出错。
后来发现不写@Column这个注解,hibernate也会映射实体里定义的字段,但是MultipartFile
类型,在数据库中找不到对应的类型,没法创建。
注意:在实体中,如果用注解@Entity和@Table标注某个实体,@Column注解写在字段上关联字段,没有写@Column注解的也会关联上,hibernate会自动在数据库中创建该字段,如果没有对应的类型像上面提到的MultipartFile,就会报错。
所以需要用注解@Transient
标注字段为临时字段,该字段不属于数据库字段。