因为项目太忙了,今天终于有时间重新学下jpa,没想到刚上来就给了我当头棒喝,连续报了好几个错,记录下。
报错信息 | 解决方案 |
---|---|
java.sql.SQLSyntaxErrorException: Table ‘sell.hibernate_sequence’ doesn’t exist | 实体类上加@GeneratedValue(strategy = GenerationType.IDENTITY) |
org.hibernate.LazyInitializationException: could not initialize proxy [com.yz.dataobject.ProductCategory#2] - no Session | 1.配置文件增加spring.jpa.open-in-view=true 2.配置文件增加spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true 3,实体类增加@Proxy(lazy = false) |
org.hibernate.exception.ConstraintViolationException: could not execute statement | 这个错误,出现的原因很多,一般是字段重复 |
java.lang.IllegalArgumentException: Parameter value element [1] did not match expected type [java.lang.String (n/a)] | 方法参数类型不对 |
java.lang.IllegalStateException: Failed to load ApplicationContext | 使用了jap不支持的方法 |
后续继续更新