I am fairly new to hibernate and this is very strange - I am trying to run a Spring-Hibernate rest application on tomcat using eclipse. I have an entity defined as below -
@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 version is as below -
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<scope>runtime</scope>
</dependency>
With this, If I run the application , it throws exception as below -
Caused by: org.hibernate.HibernateException: Missing sequence or table: bdp_billing_rec_ref_id_seq
The sequence bdp_billing_rec_ref_id_seq
exists in database, I have made it sure.
After googling the issue, according to suggestions I modified the GenerationType.AUTO to GenerationType.IDENTITY , and it worked . The Web Server started to run.
Now, the application tries to insert rows in to BillingRecordReference table after hitting a rest endpoint. At this moment, hibernate throw another exception and values did not inserted in to table.
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("DPOWNERA"."BDP_BILLING_REC_REF"."DB_ID")
The oracle version is 12c, I am running JAVA - openjdk version "1.8.0_181-1-ojdkbuild", Tomcat Version is 8.0.5.
Please suggest what could be wrong here ?