File attachment using Adf faces, EJB3 and Oracle XE database Part I

Usecase:

I want to associate files with employees (PERSON). I will have employees(PERSON) with their associated files which will hold the more information for that employees (PERSON) like (employee’s picture, list of his dependant, his Resume etc)

My ERD will have PERSON and ATTACHMENT tables, and a join table between PERSON and ATTACHMENT that is PERSON_ATTACHMENT.

The relation between PERSON AND ATTACHMENT is ONE TO MANY, A single employee (PERSON) can have many attachments.
Step # 1 Creating tables in Oracle database XE
Let’s first create the Tables in Oracle XE Database.
Open your Oracle Database XE by clicking on “Startup” select “Oracle Database 10g Express Edition” and then click on “Go to Database Home page”
Login to Oracle Database XE.
Creating PERSON  Table

PERSON table
 

PERSON table also create sequence for PERSON table
 

PERSON table
 
Create Attachment table with three columns "ATTACHMENT_ID", "FILE_CONTENT" & "FILE_NAME"

ATTACHMENT table, also create sequence for attachment table
 

ATTACHMENT table
 
Create join table between PERSON and ATTACHEMTN as "PERSON_ATTACHMENT".

PERSON_ATTACHMENT table
 

PERSON_ATTACHMENT table, make composite primary key

Create Foreign keys
 

Create Foreign keys

PERSON_ATTACHMENT table
 While creating tables we also added sequences and it causes to generate triggers as well, so in our case we need to delete these triggers, 1. In Object browser select "Triggers" in dropdown, it will show you all the triggers, in our case there will be only two triggers with the name "BI_ATTACHMENT" and "BI_PERSON"
Following are the steps to remove the triggers.

Remove these triggers as follows


 

 



To be continue-->
Comming up next
Step II Creating Entities from Database tables, Creating Session beans

Comments

Popular posts from this blog

Unable to create a server socket for listening on channel "Default[4]". The address 0:0:0:0:0:0:0:1 might be incorrect or another process is using port 8001: java.net.BindException: Address already in use: JVM_Bind.

[Deployer:149164]The domain edit lock is owned by another session in exclusive mode - hence this deployment operation cannot proceed.

ERROR: No j2ee modules detected in EAR archive. Deployment aborted. == (oracle.jdeveloper.deploy.VetoableDeployException)