java - HibernateException: Missing sequence or table and SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into
问题描述
我对hibernate相当陌生,这很奇怪-我正在尝试使用eclipse在tomcat上运行Spring-Hibernate rest应用程序。我有一个定义如下的实体 -
@Entity
@Table(name = "bdp_billing_rec_ref")
@NamedQueries(value = { @NamedQuery(name = BillingRecordReference.BILLING_RECORD_REF_DELETE_OLDER_THAN, query = "DELETE FROM BillingRecordReference WHERE updated<:date") })
public class BillingRecordReference {
@Id
@SequenceGenerator(name = "bdp_billing_rec_ref_id_seq_gen", sequenceName = "bdp_billing_rec_ref_id_seq")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "bdp_billing_rec_ref_id_seq_gen")
@Column(name = "db_id")
private Long dbId;
Oracle maven 依赖版本如下 -
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<scope>runtime</scope>
</dependency>
有了这个,如果我运行应用程序,它会抛出如下异常 -
Caused by: org.hibernate.HibernateException: Missing sequence or table: bdp_billing_rec_ref_id_seq
该序列bdp_billing_rec_ref_id_seq
存在于数据库中,我已经确定了。谷歌搜索问题后,根据建议,我将 GenerationType.AUTO 修改为 GenerationType.IDENTITY ,它起作用了。Web 服务器开始运行。
现在,应用程序在到达休息端点后尝试将行插入到 BillingRecordReference表中。此时,hibernate 抛出另一个异常并且值没有插入到表中。
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("DPOWNERA"."BDP_BILLING_REC_REF"."DB_ID")
oracle版本是12c,我运行的是JAVA-openjdk版本“1.8.0_181-1-ojdkbuild”,Tomcat版本是8.0.5。
请建议这里可能有什么问题?
解决方案
推荐阅读
- google-apps-script - 使用 Google Apps 脚本将所有 Google 表单发送到同一个表格 gid
- android - LVL 以 LICENSED 响应免费用户
- javascript - 单击按钮后如何将元素更改为默认值?
- bash - git - 使用用户名和密码将参数传递给 git
- python - Pytorch 如何在多个进程之间共享内存?
- c - 使用 sigaction、SIGKILL 和警报处理程序杀死耗时超过 3 秒的分叉进程
- angularjs - AngularJS 中的视图单元测试问题
- haskell - Haskell 中的唯一 ID/计数器
- aws-pinpoint - 如何使用 Pinpoint 创建深度链接推送通知?
- python - 有谁知道如何将 sqllite 中数据库上的列提取到数组中?