1.升级之后发现项目里集成的其他组件也需要升级
hibernate4 —>hibernate5
修改内容:
(配置文件,我用的是properties)
1.banner.charset=UTF-8 => spring.banner.charset=UTF-8
2.spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext => spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
3.spring.http.multipart.max-file-size = -1 => spring.servlet.multipart.max-file-size = -1
4.spring.http.multipart.max-request-size=-1 => spring.servlet.multipart.max-request-size=-1
。。。我大概是这么多,还有其他望补充
(maven:pm.xml)
第一步:引入hibernate
第二步:引入jdbc
遇到的问题:查询时报错
错误内容:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.air.xda.utils.common.ResultBean["data"]->com.air.xda.dto.algorithm.AlgorithmDetailEntityDto["algorithmRoot"]->com.air.xda.entity.executable.AlgorithmRoot$HibernateProxy$n4rjd4RO["hibernateLazyInitializer"])
问题所在:使用jpa做增删改查的时候出现了这个异常,原因是转化成json的时候,fasterxml.jackson将对象转换为json报错,发现有字段为null
解决方案:实体类上添加 @JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
jpa升级之后的变化
@query注解中的 ?占位符 被废弃,需要用 ?1 ?2 ?3代替
https://www.cnblogs.com/lingcheng7777/p/11662593.html