Forums Register Login

Auto Increment id in MySQL to a sequence id in Oracle Issue

+Pie Number of slices to send: Send
Hello,

I originally started testing hibernate using MySQL. I got it to work but now that I moved it to Oracle. I can't get the insertion to the database to generate the id. It keeps adding/updating an user with id = 0.

This is the error that I'm getting: Caused by: java.sql.SQLException: Invalid column type: getInt not implemented for class oracle.jdbc.driver.T4CRowidAccessor

This was my getId() - This worked in MySQL.


This is the trigger I have in Oracle

CREATE OR REPLACE TRIGGER "CHS"."USERS_TRG" BEFORE INSERT ON USERS
FOR EACH ROW
BEGIN
<<COLUMN_SEQUENCES>>
BEGIN
IF :NEW.USERID IS NULL THEN
SELECT USERS_SEQ.NEXTVAL INTO :NEW.USERID FROM DUAL;
END IF;
END COLUMN_SEQUENCES;
END;

What should I change to now make it work in Oracle?

Thanks for your help
+Pie Number of slices to send: Send
This forum is for Spring Framework questions. Not ORM questions. There is a separate forum for that.

Please post to the appropriate forum.

Moving this.

Thanks

Mark
+Pie Number of slices to send: Send
In oracle you will need to use a sequence (create sequence hibernate_sequence
start with 1
increment by 1
nomaxvalue; ) and instead of IDENTITY you can use Sequence or Native.
+Pie Number of slices to send: Send
I got this working by doing the follwing:



and also I had the wrong dialect in my hibernateProperties: <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2370 times.
Similar Threads
Auto Increment ID Field Table in the Oracle Database
SQLGrammarException: could not get next sequence value
why my oracle sequence id increases by 2 when I use hibernate to insert
Hibernate Question
Hibernate Question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:08:27.