To demonstrate the different steps involved in a Hibernate application,We will develop a console based application that can add,update,delete or search a user in the database. As discussed previously,we can use Oracle or MySQL database for storing the user information.


We’ll use a single table ‘users’ to store the user information with the following fields:





































Column Name



Data Type



Constraints



USER_ID



NUMBER



PRIMARY KEY



FIRST_NAME



TEXT



NONE



LAST_NAME



TEXT



NONE



AGE



NUMBER



NONE



EMAIL



TEXT



NONE




Create this table in the database. The syntax for the oracle is given below.


CREATE TABLE USERS(
    USER_ID NUMBER PRIMARY KEY,
    FIRST_NAME VARCHAR(20),
    LAST_NAME VARCHAR(20),
    AGE NUMBER,
    EMAIL VARCHAR(40)
);


If you are using MySQL database,you can create the table using following syntax.


CREATE TABLE USERS(
    USER_ID NUMERIC PRIMARY KEY,
    FIRST_NAME CHAR(20),
    LAST_NAME CHAR(20),
    AGE NUMERIC,
    EMAIL CHAR(40)
);

                    

Copyright © 2013 VisualBuilder. All rights reserved