https://github.com/agilecreativity/spring-oracle-hibernate-example
https://github.com/agilecreativity/spring-oracle-hibernate-example
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/agilecreativity/spring-oracle-hibernate-example
- Owner: agilecreativity
- Created: 2014-01-26T13:37:45.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-26T13:38:44.000Z (over 12 years ago)
- Last Synced: 2024-04-16T19:39:49.528Z (about 2 years ago)
- Language: Java
- Size: 109 KB
- Stars: 3
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Simple project using Oracle database with Spring, and Maven
## Installation
* You will need to have setup the Oracle database and populate the data using the script provided (see below)
* You will need to copy the Oracle's jar file and install it to manually (see below)
* Edit your hibernate.cfg.xml file to your Oracle's setup (username, password, host, port, etc)
### Install Oracle's jar manually using the following command
```
mvn install:install-file -Dfile=./ojdbc.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
```
The reason we need to do this because we have the following section in ```pom.xml``` file
com.oracle
ojdbc6
11.2.0
### You will also need to create following table in Oracle using the following DDL.
CREATE TABLE DBUSER (
USER_ID NUMBER(12) NOT NULL,
USER_NAME VARCHAR2(20) NOT NULL,
CREATED_BY VARCHAR2(20) NOT NULL,
CREATED_DATE DATE NOT NULL,
PRIMARY KEY (USER_ID)
);
CREATE TABLE DEPARTMENT (
DEPT_ID NUMBER(12) NOT NULL,
DEPT_NAME VARCHAR2(20) NOT NULL,
PRIMARY KEY (DEPT_ID)
);
CREATE TABLE EMPLOYEE (
EMP_ID NUMBER(12) NOT NULL,
FIRST_NAME VARCHAR2(50) NOT NULL,
LAST_NAME VARCHAR2(50) NOT NULL,
BIRTH_DATE DATE NULL,
CELL_PHONE VARCHAR2(15) NULL,
DEPT_ID NUMBER(12) NULL,
PRIMARY KEY(EMP_ID)
);
ALTER TABLE EMPLOYEE ADD (
CONSTRAINT EMP_DEPT_FK
FOREIGN KEY (EMP_ID)
REFERENCES DEPARTMENT(DEPT_ID));
CREATE SEQUENCE EMP_SEQ
START WITH 0
INCREMENT BY 1
MINVALUE 0
NOCACHE
NOCYCLE
NOORDER;
### Edit your hibernate configuration file to your environment
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@:1521:
YOUR_DB_LOGIN
YOUR_DB_PASSWORD
org.hibernate.dialect.Oracle10gDialect
YOUR_SCHEMA_NAME
true
### Once this is done you can then
Then you can run the following command
```
$mvn clean eclipse:eclipse install
```
If you want so use it from Eclipse then just use File->Import
### Author
[Burin Choomnuan](https://github.com/agilecoders)