Forums Register Login

ERROR: ORA-02289: sequence does not exist

+Pie Number of slices to send: Send
I am creating a basic hibernate application for employee table in which I am adding, updating, deleting and displaying the record with the help of ManageEmployee class.

Actually, ManageEmployee is my test class and i am using Employee.java and Employee.hbm.xml file to do above things.

Details: Database: Oracle 11 g Hibernate version: hibernate-release-4.3.8.Final Java Version: Java 1.8

Employee Table Details:

USER_ID NUMBER(15,0) No 1 1
FIRST_NAME VARCHAR2(20 BYTE) Yes 2
LAST_NAME VARCHAR2(20 BYTE) Yes 3
SALARY NUMBER(10,0) Yes 4

Error Log: you can see in the log that error is coming 3 times because I am adding Employee object 3 times in ManageEmployee.java class with addEmployee(...) method so I am assuming that problem is with the sequence generator for the column id.

Here I am using naive generator. i.g. Integer empID1 = ME.addEmployee("Zara", "Ali", 1000);



ManageEmployee.java file Code:


Mapping File:
+Pie Number of slices to send: Send
Have you asked Hibernate to create your db for you, or have you done it by hand?
If the latter then you will (IIRC) need to create the SEQUENCE that Hibernate is to use for your IDs, which will also mean changing your XML to tell Hibernate what SEQUENCE to use.
+Pie Number of slices to send: Send

Hi,

I have created database and table myself.

If the latter then you will (IIRC) need to create the SEQUENCE that Hibernate is to use for your IDs, which will also mean changing your XML to tell Hibernate what SEQUENCE to use.


How we can implement this?
+Pie Number of slices to send: Send
here is my model class

+Pie Number of slices to send: Send
 

Thakur Sachin Singh wrote:
Hi,

I have created database and table myself.

If the latter then you will (IIRC) need to create the SEQUENCE that Hibernate is to use for your IDs, which will also mean changing your XML to tell Hibernate what SEQUENCE to use.


How we can implement this?



You'll need to read up on Oracle sequences and how they function, as well as telling Hibernate that you are using a SEQUENCE (section 5.1.2.2.4) rather than a native generator.

(fixed links)
+Pie Number of slices to send: Send
Hi,

@Dave: Thanks for the information, now i have fixed my problem.

I have created a sequence in oracle database by the below query and updated my hbm.xml file



+Pie Number of slices to send: Send
That's good..

Thanks for coming back and posting your fix.
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 29177 times.
Similar Threads
Hibenate & Oracle 10g
SQLGrammarException: could not get next sequence value
spring + hibernate
Hibernate project Exception
hibernate exception SQLGrammarException could not fetch initial value for increment
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:44:42.