升级Hibernate版本后,@ JoinColumn不起作用

时间:2019-01-03 08:58:03

标签: java hibernate hibernate-mapping

从Hibernate 3迁移到Hibernate 5.2.17.Final和Spring从3迁移到5.0.5.RELEASE版本后,我的某些实体发生了奇怪的行为

当我尝试保存实体 HstData 时,收到错误+------+------------+--------------------+---------------------+--------------------+---------------------+ | Name | Date | cat1_grouped.value | cat1_grouped.number | cat2_grouped.value | cat2_grouped.number | +------+------------+--------------------+---------------------+--------------------+---------------------+ | John | 2019-01-03 | AA | 10 | NN | 12 | | | | AB | 11 | MM | 13 | | | | | | | | +------+------------+--------------------+---------------------+--------------------+---------------------+ 。 但是我在这里有注释:

SqlExceptionHelper - Invalid object name 'hst_events'

HstEvents类非常简单:

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "hst_events_id")
private HstEvents hstEvents;

完整的堆栈跟踪在这里:

@Entity
@EqualsAndHashCode(exclude = "id")
@Table(name = "hst_events")
public class HstEvents {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Getter
    private Long id;

    @NotNull
    @Lob
    @Getter
    @Setter
    private byte[] data;
}

首先,我认为自定义命名策略无法正常工作,但是当我禁用它时,问题再次出现。

0 个答案:

没有答案