Hibernate Oracle12c Identity : mysterious problem

Hello everyone,
I’m trying to configure an existing Spring Boot application to use an Oracle12c database, and I’ve got a problem with Identity columns.

Oracle12c supports identities natively, and i set the strategy as IDENTITY, but hibernate seems to ignore my identity column and try to use

 select hibernate_sequence.nextval from dual

I home someone can help me.


This is the log:

Hibernate: select userlogini0_.id as id1_0_, userlogini0_.created_date as created_date2_0_, userlogini0_.register_number as register_number3_0_, userlogini0_.session_id as session_id4_0_, userlogini0_.session_status as session_status5_0_, userlogini0_.updated_date as updated_date6_0_, userlogini0_.user_bank as user_bank7_0_, userlogini0_.user_name as user_name8_0_, userlogini0_.user_structure as user_structure9_0_ from user_login_info userlogini0_ where userlogini0_.register_number=? and userlogini0_.user_name=? and userlogini0_.user_bank=? and userlogini0_.user_structure=? and userlogini0_.session_status=?
Hibernate: insert into user_login_info (created_date, register_number, session_id, session_status, updated_date, user_bank, user_name, user_structure) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select hibernate_sequence.nextval from dual
2021-03-03 20:39:23.707  WARN 8 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 2289, SQLState: 42000
2021-03-03 20:39:23.707 ERROR 8 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ORA-02289: sequence does not exist

2021-03-03 20:39:23.724 ERROR 8 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/be-profiling-clm] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause

oracle.jdbc.OracleDatabaseException: ORA-02289: sequence does not exist

These are my configs:

org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.7.Final}
o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect

This is one of the table:

CREATE TABLE user_login_info 
	created_date TIMESTAMP (6) NOT NULL , 
	register_number VARCHAR2(255 CHAR) NOT NULL , 
	session_id VARCHAR2(255 CHAR) NOT NULL , 
	session_status VARCHAR2(255 CHAR) NOT NULL , 
	updated_date TIMESTAMP (6) NOT NULL , 
	user_structure VARCHAR2(255 CHAR) NOT NULL , 

and this is my entity:

@Table(name = "user_login_info")
public class UserLoginInfo {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", unique = true, nullable = false, updatable = false)
    private Long id;

    @Column(name = "REGISTER_NUMBER", nullable = false, updatable = false)
    private String registerNumber;
    @Column(name = "USER_NAME", nullable = false, updatable = false)
    private String userName;

    @Column(name = "USER_STRUCTURE", nullable = false, updatable = false)
    private String userStructure;

    @Column(name = "SESSION_ID", unique = true, nullable = false, updatable = false)
    private String sessionId;

    @Column(name = "SESSION_STATUS", nullable = false)
    private SessionStatus sessionStatus;

    @Column(name = "CREATED_DATE", nullable = false, updatable = false)
    private LocalDateTime createdDate;

    @Column(name = "UPDATED_DATE", nullable = false)
    private LocalDateTime updatedDate;


It seems Hibernate is trying to fetch the sequence for a different entity though as the insert for the user_login_info was successful.

Thanks Beikov,
you’re right! there is no errors in my implementation, there was another entity in project without the correct strategy annotation. I was looking in wrong place. My bad…