# Hibernate Oracle12c Identity : mysterious problem

**URL:** <https://discourse.hibernate.org/t/hibernate-oracle12c-identity-mysterious-problem/5135>\
**Category:** Hibernate ORM\
**Created:** [March 3, 2021, 9:00pm UTC](https://discourse.hibernate.org/t/hibernate-oracle12c-identity-mysterious-problem/5135 "2021-03-03T21:00:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nassiesse](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@Nassiesse](https://discourse.hibernate.org/u/Nassiesse)\
**Post date:** [March 3, 2021, 9:00pm UTC](https://discourse.hibernate.org/t/hibernate-oracle12c-identity-mysterious-problem/5135/1 "2021-03-03T21:00:38Z")

</div>

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

```auto
 select hibernate_sequence.nextval from dual

```

I home someone can help me.

Thanks

This is the log:

```auto
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:

```auto
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:

```auto
CREATE TABLE user_login_info 
(		
	id NUMBER(19,0) GENERATED ALWAYS AS IDENTITY INCREMENT BY 1 START WITH 1 NOT NULL , 
	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 , 
	PRIMARY KEY (id)
);

```

and this is my entity:

```auto
@Data
@Entity
@Table(name = "user_login_info")
public class UserLoginInfo {

    @Id
    @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)
    @Enumerated(EnumType.STRING)
    private SessionStatus sessionStatus;

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

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

}

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [March 4, 2021, 8:50am UTC](https://discourse.hibernate.org/t/hibernate-oracle12c-identity-mysterious-problem/5135/2 "2021-03-04T08:50:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nassiesse](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@Nassiesse](https://discourse.hibernate.org/u/Nassiesse)\
**Post date:** [March 4, 2021, 9:24pm UTC](https://discourse.hibernate.org/t/hibernate-oracle12c-identity-mysterious-problem/5135/3 "2021-03-04T21:24:00Z")

</div>

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…
