Create your JPA project and entities – from mysql , EJB Project , using RAD IBM 8.5.1

Good Day!,

Create your JPA project and entities – from mysql ,  EJB Project , using RAD IBM 8.5.1 :

1.) First steps, create MySQL tables for Student System, My database name “fndong_work_db“.

use fndong_work_db;

create table STUDENT(
    Stud_ID INT NOT NULL AUTO_INCREMENT,
    Stud_fname VARCHAR(35) NOT NULL,
    Stud_lname VARCHAR(35) NOT NULL,
    Stud_Icnumber CHAR(12),
    Stud_comment VARCHAR (200),
    Stud_email VARCHAR (50),
    Stud_dateCreated DATE,
   PRIMARY KEY (Stud_ID)
) ENGINE=InnoDB;

create table STUDENT_COURSE(
    ID INT NOT NULL AUTO_INCREMENT,
    Stud_ID int not null,
    Stud_CourseID char(4),
    Stud_DateOfContact DATE,
    Stud_EndDate DATE,
    foreign key (Stud_CourseID) references COURSE(Stud_CourseID),
    foreign key (Stud_ID) references STUDENT(Stud_ID),
    PRIMARY KEY (ID,Stud_ID,Stud_CourseID)
)ENGINE=InnoDB;

create table COURSE(
    Stud_CourseID char (4),
    Stud_CourseName VARCHAR(50),
   PRIMARY KEY (Stud_CourseID)
)ENGINE=InnoDB;

create table STUDENT_GRADE(
    Stud_ID INT NOT NULL AUTO_INCREMENT,
    Stud_GradeID Char(4),
    Stud_CourseID char (4),
    Stud_DateOut DATE,
    Stud_GradeComment VARCHAR(200),
    foreign key (Stud_CourseID) references COURSE(Stud_CourseID),
    foreign key (Stud_ID) references STUDENT(Stud_ID),
    PRIMARY KEY (Stud_ID,Stud_GradeID)
)ENGINE=InnoDB;

2.) Insert data in the tables.

insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ROSMAN','ULU YAM','990211052112','','rosman@gmail.com ','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ALI','MOHKTAR','010211062114','','mohktar99@gmail.com','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('ERIC','CANTONA','010211042112','','cantonamu_eric@gmail.com','2016-02-14');
insert into STUDENT (Stud_fname, Stud_lname,Stud_Icnumber,Stud_comment,Stud_email,Stud_dateCreated) values ('AH MENG','LIEW','000211032111','','lewmeng22@gmail.com','2016-02-14');

insert into COURSE  (Stud_CourseID,Stud_CourseName) values ('ITUC','INFORMATION TECHNOLOGY'); 
insert into COURSE  (Stud_CourseID,Stud_CourseName) values ('ACUC','ACCOUNTANT');  
insert into COURSE  (Stud_CourseID,Stud_CourseName)  values ('BUUC','BUSINESS'); 
insert into COURSE  (Stud_CourseID,Stud_CourseName)  values ('ENUC','ENGINERING');

insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (1,'ITUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (2,'ITUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (3,'BUUC','2016-02-14','2019-02-14');
insert into STUDENT_COURSE (Stud_ID,Stud_CourseID,Stud_DateOfContact,Stud_EndDate) values (4,'BUUC','2016-02-14','2019-02-14');

3.) Create  EJB project “studentEJB” and EAR file studEJBEAR.

4.jpg

4.) Create JPA Entity.

4.1.) Create package “com.fndong.entities”

4.2.) Right Click Project > Properties > Select “Project Facet” > Enable JPA.

5.jpg

5.) Create Entities from Table , Right Click Project > JPA Tools > Generate Entities from Tables…

6.jpg

6.) Select tables.

7.jpg

Next Button

8.jpg

Key Generator – Identity

9.jpg

7.) Generated automatically entities.

8.) Creating Session Bean and Bean Interface.

8.1.) Right Click ejbModule > New > Session Bean

10.jpg

8.2.) Add the Session Bean (Business Logic ) with Interface.

Session EJBs Implement Business Logic:
– Session beans implement business logic. A session bean instance serves one client at a time. There are two types of session beans: stateful and stateless.

11.jpg

9.) Structure Project EJB with Remote Client.

12.jpg

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s