1

I am working on application where three environments are there. test, int and production db.

I have a table, if I observe the generated SQL in SQL developer for primary key

ID" NUMBER GENERATED BY DEFAULT AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE NOT NULL ENABLE,

If I see on table it looks like...

"SCHEMA"."ISEQ$$_97103".nextval

on JPA/eclipselink entity I used this ISEQ$$_97103 sequence generator it worked on test environment.

But, when I executed this on INT environment it throws error ISEQ$$_97103 sequence does not exist. I observed that, it's a different name in INT database.

As they system generated names they would be different.

I tried with the following link but no use

https://www.thoughts-on-java.org/hibernate-tips-use-auto-incremented-column-primary-key/

How to specify in JPA use system generated identity names from table? is there any way? or is is mandatory that the name should be same in three environments.

Here is my entity class:

@Entity
@Table(name = "T_MY_TABLE")
public class MyDataEntity implements Serializable {

@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;


// other colums, getters/setters

}

Error I am getting

Internal Exception: java.sql.SQLException: ORA-02289: sequence does not exist
Error Code: 2289
Call: SELECT SEQ_GEN_IDENTITY.NEXTVAL FROM DUAL
Query: ValueReadQuery(sql="SELECT SEQ_GEN_IDENTITY.NEXTVAL FROM DUAL

I am really wondering, I haven't mentioned anything related to Sequence but why it's reading the value from sequence.

Naveen Kocherla
  • 399
  • 9
  • 27
  • Yes, I tried but it's showing SEQUNCE DOES NOT EXIST error.. Exactly this error... https://stackoverflow.com/questions/43681652/jpa-isnt-able-to-create-persist-an-ejb – Naveen Kocherla Jun 15 '18 at 12:13
  • If you have an "IDENTITY" column then you must set the JPA generator strategy to "IDENTITY". But then you don't post any JPA class –  Jun 15 '18 at 12:17
  • What is throwing the error exactly? Why would JPA care about the name of the identity object in the database? Please note that the error in https://stackoverflow.com/questions/43681652/jpa-isnt-able-to-create-persist-an-ejb was caused because they said they were using an identity object, but one did NOT exist in the database. Check your INT environment if you expect it to be there, as it seems your environments are setup differently. – Chris Jun 15 '18 at 15:32
  • @Chris, have added the error what I am getting. – Naveen Kocherla Jun 18 '18 at 04:18
  • It's saying that, internally it creates the sequence @https://lalitkumarb.wordpress.com/category/oracle-12c-installation-new-features/ is there any possibility to give the name to system generated sequence ? – Naveen Kocherla Jun 18 '18 at 06:37
  • Do you want identity or sequence? if you are able to change the strategy, sequence or table sequencing are better options - anything that allows preallocation is more efficient. In this case though, are all 3 environments the same database? I don't understand why this would work in one environment but not another - Oracle only released identity support in 12 which isn't supported in the EclipseLink OracleDatabase platform that I'm aware of. You would have to implement it yourself by extending the platform, but I would strongly suggest using another strategy. – Chris Jun 18 '18 at 14:10
  • @Chris, thanks for the comment, have changed to sequence strategy instead of identity.. problem solved – Naveen Kocherla Jun 19 '18 at 06:13

0 Answers0