HIBERNATE TUTORIAL

HIBERNATE - Hibernate Complete Example

Database Scripts

 

--Drop Tables
DROP TABLE "APP"."ATTACHMENT";
DROP TABLE "APP"."CATEGORY";
DROP TABLE "APP"."CATEGORY_PROP";
DROP TABLE "APP"."DOCUMENT";
DROP TABLE "APP"."DOCUMENT_ATTACHMENT";
DROP TABLE "APP"."DOCUMENT_KEYWORDS";
DROP TABLE "APP"."DOCUMENT_PROP";
DROP TABLE "APP"."ENTRY";
DROP TABLE "APP"."GROUP";
DROP TABLE "APP"."GROUP_PROP";
DROP TABLE "APP"."IDGENERATOR";
DROP TABLE "APP"."KEYWORD";
DROP TABLE "APP"."USER";
DROP TABLE "APP"."USER_GROUP";
DROP TABLE "APP"."USER_PROP";

-- Table: "APP"."ATTACHMENT"
CREATE TABLE "APP"."ATTACHMENT"
(
"ATTACHMENT_ID" numeric NOT NULL,
"DOCUMENT_ID" numeric,
"ATTACHMEMT_PATH" varchar,
"ATTACHMENT_SIZE" numeric,
CONSTRAINT "ATTACHMENT_pkey" PRIMARY KEY ("ATTACHMENT_ID")
);

-- Table: "APP"."CATEGORY"
CREATE TABLE "APP"."CATEGORY"
(
"CATAGORY_ID" numeric NOT NULL,
"CATEGORY_NAME" varchar,
"CATEGORY_DESCRIPTION" varchar,
"CREATED_BY" numeric,
"CREATION_DATE" date,
"MODIFIED_BY" numeric,
"MODIFICATION_DATE" date,
"DELETED_BY" numeric,
"DELETE_DATE" date,
"PARENT_CATAGORY" numeric,
CONSTRAINT "CATEGORY_pkey" PRIMARY KEY ("CATAGORY_ID"),
CONSTRAINT "CATEGORY_PARENT_CATAGORY_fkey" FOREIGN KEY ("PARENT_CATAGORY") REFERENCES "APP"."CATEGORY" ("CATAGORY_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT authorfk FOREIGN KEY ("CREATED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT deletorfk FOREIGN KEY ("DELETED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT editorfk FOREIGN KEY ("MODIFIED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."CATEGORY_PROP"
CREATE TABLE "APP"."CATEGORY_PROP"
(
"CATEGORY_PROP_ID" numeric NOT NULL,
"CATEGORY_ID" numeric,
"PROP_NAME" varchar,
"PROP_VALUE" varchar,
CONSTRAINT "CATEGORY_PROP_pkey" PRIMARY KEY ("CATEGORY_PROP_ID"),
CONSTRAINT "CATEGORY_PROP_CATEGORY_ID_fkey" FOREIGN KEY ("CATEGORY_ID") REFERENCES "APP"."CATEGORY" ("CATAGORY_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."DOCUMENT"
CREATE TABLE "APP"."DOCUMENT"
(
"DOCUMENT_ID" numeric NOT NULL,
"DOCUMENT_TITLE" varchar,
"DOCUMENT_BODY" varchar,
"DOCUMENT_SUMMARY" varchar,
"CREATED_BY" numeric,
"CREATION_DATE" date,
"MODIFIED_BY" numeric,
"MODIFICATION_DATE" date,
"DELETED_BY" numeric,
"DELETED_DATE" date,
"DOCUMENT_VERSION" numeric,
"DOCUMENT_STATUS" numeric,
"ENTRY_ID" numeric,
CONSTRAINT "DOCUMENT_pkey" PRIMARY KEY ("DOCUMENT_ID"),
CONSTRAINT "DOCUMENT_ENTRY_ID_fkey" FOREIGN KEY ("ENTRY_ID") REFERENCES "APP"."ENTRY" ("ENTRY_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT authorfk FOREIGN KEY ("CREATED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT deletorfk FOREIGN KEY ("DELETED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT editorfk FOREIGN KEY ("MODIFIED_BY") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."DOCUMENT_ATTACHMENT"
CREATE TABLE "APP"."DOCUMENT_ATTACHMENT"
(
"DOCUMENT_ATTACHMENT_ID" numeric NOT NULL,
"ATTACHMENT_ID" numeric,
"DOCUMENT_ID" numeric,
"ATTACHMENT_PATH" varchar,
"ATTACHMENT_SIZE" numeric,
CONSTRAINT "DOCUMENT_ATTACHMENT_pkey" PRIMARY KEY ("DOCUMENT_ATTACHMENT_ID"),
CONSTRAINT "DOCUMENT_ATTACHMENT_ATTACHMENT_ID_fkey" FOREIGN KEY ("ATTACHMENT_ID") REFERENCES "APP"."ATTACHMENT" ("ATTACHMENT_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "DOCUMENT_ATTACHMENT_DOCUMENT_ID_fkey" FOREIGN KEY ("DOCUMENT_ID") REFERENCES "APP"."DOCUMENT" ("DOCUMENT_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."DOCUMENT_KEYWORDS"
CREATE TABLE "APP"."DOCUMENT_KEYWORDS"
(
"DOCUMENT_KEYWORD_ID" numeric NOT NULL,
"DOCUMENT_ID" numeric,
"KEYWORD_ID" numeric,
z CONSTRAINT "DOCUMENT_KEYWORDS_pkey" PRIMARY KEY ("DOCUMENT_KEYWORD_ID"),
CONSTRAINT "DOCUMENT_KEYWORDS_DOCUMENT_ID_fkey" FOREIGN KEY ("DOCUMENT_ID") REFERENCES "APP"."DOCUMENT" ("DOCUMENT_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT keywordidfk FOREIGN KEY ("KEYWORD_ID") REFERENCES "APP"."KEYWORD" ("KEYWORD_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."DOCUMENT_PROP"
CREATE TABLE "APP"."DOCUMENT_PROP"
(
document_prop_id numeric NOT NULL,
document_id numeric NOT NULL,
prop_name varchar NOT NULL,
prop_value varchar,
prop_value_details varchar,
CONSTRAINT "DOCUMENT_PROP_pkey" PRIMARY KEY (document_prop_id),
CONSTRAINT "DOCUMENT_PROP_document_id_fkey" FOREIGN KEY (document_id) REFERENCES "APP"."DOCUMENT" ("DOCUMENT_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."ENTRY"
CREATE TABLE "APP"."ENTRY"
(
"ENTRY_ID" numeric NOT NULL,
"CATEGORY_ID" numeric,
CONSTRAINT "ENTRY_pkey" PRIMARY KEY ("ENTRY_ID"),
CONSTRAINT "ENTRY_CATEGORY_ID_fkey" FOREIGN KEY ("CATEGORY_ID") REFERENCES "APP"."CATEGORY" ("CATAGORY_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."GROUP"
CREATE TABLE "APP"."GROUP"
(
"GROUP_ID" numeric NOT NULL,
"GROUP_NAME" varchar,
"GROUP_DESCRIPTION" varchar,
"CREATED_BY" numeric,
"CREATION_DATE" date,
"MODIFIED_BY" numeric,
"MODIFICATION_DATE" date,
"DELETED_BY" numeric,
"DELETE_DATE" date,
CONSTRAINT "GROUP_ID_pk" PRIMARY KEY ("GROUP_ID") USING INDEX TABLESPACE apptablespace
);

-- Table: "APP"."GROUP_PROP"
CREATE TABLE "APP"."GROUP_PROP"
(
group_prop_id numeric NOT NULL,
group_id numeric NOT NULL,
prop_name varchar NOT NULL,
prop_value varchar,
prop_value_details varchar,
CONSTRAINT "GROUP_PROP_pkey" PRIMARY KEY (group_prop_id),
CONSTRAINT "GROUP_PROP_group_id_fkey" FOREIGN KEY (group_id) REFERENCES "APP"."GROUP" ("GROUP_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);
-- Table: "APP"."IDGENERATOR"
CREATE TABLE "APP"."IDGENERATOR"
(
id numeric NOT NULL,
next_value numeric NOT NULL,
CONSTRAINT "IDGENERATOR_pkey" PRIMARY KEY (id)
);

-- Table: "APP"."KEYWORD"
CREATE TABLE "APP"."KEYWORD"
(
"KEYWORD_ID" numeric NOT NULL,
"KEYWORD_NAME" varchar,
"KEYWORD_DESCRIPTION" varchar,
CONSTRAINT "KEYWORD_pkey" PRIMARY KEY ("KEYWORD_ID")
);


-- Table: "APP"."USER"
CREATE TABLE "APP"."USER"
(
"USER_ID" numeric NOT NULL,
"USER_NAME" varchar,
"USER_PASSWORD" varchar,
"USER_FIRST_NAME" varchar,
"USER_LAST_NAME" varchar,
"CREATION_DATE" date,
"CREATED_BY" numeric,
"MODIFICATION_DATE" date,
"MODIFIED_BY" numeric,
"DELETE_DATE" date,
"DELETED_BY" numeric,
CONSTRAINT "USER_pkey" PRIMARY KEY ("USER_ID")
);

-- Table: "APP"."USER_GROUP"
CREATE TABLE "APP"."USER_GROUP"
(
"USER_GROUP" numeric NOT NULL,
"USER_ID" numeric,
"GROUP_ID" numeric,
CONSTRAINT "USER_GROUP_pkey" PRIMARY KEY ("USER_GROUP"),
CONSTRAINT "USER_GROUP_GROUP_ID_fkey" FOREIGN KEY ("GROUP_ID") REFERENCES "APP"."GROUP" ("GROUP_ID") ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT "USER_GROUP_USER_ID_fkey" FOREIGN KEY ("USER_ID") REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);

-- Table: "APP"."USER_PROP"
CREATE TABLE "APP"."USER_PROP"
(
user_prop_id numeric NOT NULL,
user_id numeric NOT NULL,
prop_name varchar NOT NULL,
prop_value varchar,
prop_value_details varchar,
CONSTRAINT "USER_PROP_pkey" PRIMARY KEY (user_prop_id),
CONSTRAINT "USER_PROP_user_id_fkey" FOREIGN KEY (user_id) REFERENCES "APP"."USER" ("USER_ID") ON UPDATE NO ACTION ON DELETE NO ACTION
);



 

Hibernate tutorial
Introduction to Hibernate
Overview of Hibernate
Features of Hibernate
Getting Started with Hibernate
Hibernate O/R Mapping
Hibernate Mapping In Depth
Hibernate Query Language
Hibernate Complete Example

Introduction

Database scheme
Basic entities
Categories and Documents
Database Scripts
Database tables Overview
hbm files
Complete Code Download

Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions