Posts

Showing posts with the label primary key

Hibernate CRUD operations with auto increment in Oracle SQL with examples

Image
Previously I was explained Hibernate CRUD Operations without Auto Increment column. Here I am explaining how to do Hibernate CRUD operations with Primary key column as auto increment in Oracle SQL with examples. There will be slight difference in pseudo code compare to the previous example. But, mostly the same classes I have used to maintain the consistency. Before going to write the java logic, we have small work to do in the database to create the table and sequence. Please execute the below lines of SQL script in your SQL prompt or SQL developer. To create the table with primary key: create table USER_INFO(user_id NUMBER,user_name VARCHAR2(50),password VARCHAR2(50),CONSTRAINT user_id_pk PRIMARY KEY(user_id)); To alter the Primary Key Constraint: alter table USER_INFO ADD CONSTRAINT user_id_pk primary key(user_id); To create the sequence: create sequence user_sequence start with 1 increment by 1 nomaxvalue; That's it we are done with our work in database side. Now,