This assessment focuses on using Java Persistence API (JPA), Object Relational Mapping (ORM) and Java Persistence Query Language (JPQL) technologies in software application development. In this...

1 answer below »
This assessment focuses on using Java Persistence API (JPA), Object Relational Mapping (ORM) and Java Persistence Query Language (JPQL) technologies in software application development. In this assessment you will design and deliver a software solution that fulfills the requirements (storing and retrieving data in Derby database server using JPA, ORM, and JPQL) specified in the business case. Please use Netbeans 8.2 as the IDE for completing it as it is the suggested editor. Please do not use any other IDE other than Netbeans.


Microsoft Word - COIT13235 Assessment-2 Specification and Marking Criteria COIT13235 Assessment-2 Specification and Marking Criteria 1 COIT13235 Enterprise Software Development Term 2/2018 Assessment 2 Specification and Marking Criteria The Budget Cars (BC) is a second-hand car sales company based in Sydney. As a part of its growth strategy BC is now planning to implement a 3-tier enterprise application (e-business) system that implements presentation, business, and persistence tiers. The Chief Technical Officer (CTO) of BC has decided to use Java Enterprise Edition (JEE) and related technologies to build the system. As a software developer, you are designated to design and develop the prototype of the proposed system for BC. To accomplish this task, you are required to divide the design and development work into two phases. This assessment (Assessment -2) is the first phase of the project. In this assessment you are required to design, implement, and test the persistence tier of the proposed prototype system. In Assessment-3, you will design, implement, and test the presentation and business tiers to deliver a fully functional enterprise web based application that follows 3-tier application architecture and design principles. A good design and implementation of this assessment is important for Assessment-3 as it (the persistence tier that you implement in this assessment) will be integrated with other 2 tiers (presentation and business tiers) of Assessment-3 as the next phase of the development. The specification of this assessment is as follows. 1. BC sells variety of family and sports cars (make and models). Make refers to manufacturer or brand such as Suzuki, Toyota, Mitsubishi, Nissan. And, models refer to Liana, Echo, Lancer, and Pulsar. The CTO has suggested you to visit the http://www.carsales.com.au website to develop your knowledge on current makes and models of cars in market. A major assumption is that these cars share some common or generic properties of car such as make, model, year of manufacture, registration number, manual/automatic transmission, number of seats, colour, and price of the car. 2. In order to reduce code redundancy, in this assessment you must implement inheritance mapping using ORM (Object Relational Mapping) technology. To meet the requirements of this assessment requirements, you must: a. Implement at least 1 superclass entity (e.g. make of the car) and use either the Joined- Subclass Strategy (detailed on page 170 of the textbook) or Mapped Superclass Strategy (detailed on page 174 to 175 of the textbook) to design entity classes. b. Implement at least 2 subclass entities (e.g. models of the car) that inherit the above superclass (e.g. make entity) to derive common properties and/or operations. These inherited classes will have some additional attributes on its own such as whether or not the car has inbuilt-navigator, audio, air conditioning, child safety logs, and fog lights. You are free to consider any additional features as appropriate. c. You must be able to store the information of all customers who purchase cars. The customer information may contain data like Customer ID, first name, last name, street address, suburb, state, postcode, email address, mobile phone number. COIT13235 Assessment-2 Specification and Marking Criteria 2 d. You must also be able to store the sales information (what was sold to who). The sales information may contain data such as sales ID, date of sales, customer, car. e. In your ORM design, the relationship between customer and sales entities must be one- to-many, i.e. a customer can buy many cars. Refer pages 156 to 159 of the textbook to understand the entity relationships. 3. The car, customer, and sales data must be persisted into a Derby database. You are required to use Java Persistence API (JPA 2 or higher) to persist the product information into a Derby database. To demonstrate success, you are required to implement all the entities and a standalone Java application (with a main method – public static void main (String[] args) ) to persist and retrieve above data (such as car, customer, sales). You must implement JPQL (Java Persistence Query Language) to retrieve data from the database. You can use NamedQuery or Dynamic Query or the combination to implement functionalities for data retrievals. To submit your assessment, you need to provide: a. The design of all entities. You are required to describe the structures of these entities, their inheritance hierarchy, or relationship. b. The complete implementation code of the persistence tier, including: Java source code, the Maven POM file and persistence XML file within a standard Maven directory structure (for example see Listing 2-53, page 63 of the textbook). That means the code can be compiled and run directly in the Java EE environment that is used in this course without any further revision/redevelopment. c. The test instruction. You are required to provide detailed instructions on how to run the application. d. You must persist at least 2 cars, 2 customers, and 2 sales for each customer. These test data can be either hard-coded in your programs or you can use command prompts to input the data. Your design and test must be documented in a single Microsoft Word document. You must submit all the required files in a zip file (i.e. Word document and project files). The maximum mark of this assessment is 25. The marking criteria of this assessment are detailed in next page. COIT13235 Assessment-2 Specification and Marking Criteria 3 COIT13235 Enterprise Software Development Term 2/2018 Marking Criteria Criterion Description Mark available 1 Design documentation 1.1 Entity designs (variables, and getter and setter methods) 2 1.2 Short description of each entity 2 1.3 Class diagram that shows all entities and their relationships (one to one, one to many) 3 1.4 Description of inheritance hierarchy or relationship 2 2 Application scenario and test instructions 2.1 Coverage of application (introduction and features) 2 2.2 User instruction on how to run the application 1 2.3 Screenshots and descriptions of inputs and outputs 2 3 Software 3.1 Codes compile and execute without any error 1 3.2 Conformance between given requirement specification and the implementation of entities 2 3.3 Functionality of data persistence 3 3.3 Functionality of data retrieval (implements JPQL to retrieve data) 3 4 Others 4.1 In-line comments, 1 4.2 Variable naming convention and code readability 1 SUB-TOTAL 25 A Penalty of 4 marks will apply if the Book and CD entities (as they appear in the textbook) are reused Late Penalty (5% each calendar day) Plagiarism Penalty TOTAL FOR THIS ASSESSMENT 25
Answered Same DayAug 21, 2020COIT13235Central Queensland University

Answer To: This assessment focuses on using Java Persistence API (JPA), Object Relational Mapping (ORM) and...

Prateek answered on Aug 24 2020
135 Votes
jpqldemo/pom.xml

4.0.0
com.tfth
jpqldemo
1.0-SNAPSHOT
jar

UTF-8
1.8
1.8



org.apache.derby
derbyclient
10.14.2.0


javax.persistence
javax.persistence-api
2.2


org.eclipse.persistence
eclipselink
2.5.2


org.eclipse.persistence
org.eclipse.persistence.jpa.modelgen.processor
2.5.2
provided


jpqldemo/src/main/java/com/tfth/jpqldemo/Car.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Car.java
package com.tfth.jpqldemo;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@Table(name = "CAR")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name="model")
public abstract class Car implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private long carID;
    private String make;
    private String model;
    private long year_of_manufacture;
    private String registration_number;
    private String transmission_type;
    private int number_of_seats;
    private String colour;
    private long price;
    public Car() {
    }
    Car(long carID,String make, String model,long year_of_manufacture,String registration_number,String transmission_type,int number_of_seats,String colour,long price){
 
       this.carID = carID;
        this.make = make;
        this.model = model;
        this.year_of_manufacture = year_of_manufacture;
        this.registration_number = registration_number;
        this.transmission_type = transmission_type;
        this.number_of_seats = number_of_seats;
        this.colour=colour;
        this.price = price;
    }
    public Long getId() {
        return carID;
    }
    public String getMake() {
         return make;
    }
    public String getModel() {
         return model;
    }
    @Override
    public String toString() {
        return String.format("%d, %s, %s", this.carID, this.make, this.model);
    }
}
jpqldemo/src/main/java/com/tfth/jpqldemo/Customer.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Customer.java
package com.tfth.jpqldemo;
import java.io.Serializable;
import javax.persistence.*;
import java.util.*;
@Entity
public class Customer implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long customerID;
    private String firstname;
    private String lastname;
    private String streetaddress;
    private String suburb;
    private String state;
    private String postcode;
    private String emailaddress;
    private String mobilenumber;
    public Customer() {
    }
    Customer(long customerID,String firstname,String lastname,String streetaddress,String suburb,String state,String postcode,String emailaddress,String mobilenumber) {
        this.customerID = customerID;
        this.firstname = firstname;
        this.lastname = lastname;
        this.streetaddress = streetaddress;
        this.suburb = suburb;
        this.state = state;
        this.postcode = postcode;
        this.emailaddress = emailaddress;
        this.mobilenumber = mobilenumber;
    }
    public Long getcustomerID() {
        return customerID;
    }
    public String getfirstname() {
         return firstname;
    }
    public String getlastname() {
         return lastname;
    }
    public String getstreetaddress() {
         return streetaddress;
    }
    public String getsuburb() {
         return suburb;
    }

    public String getstate() {
         return state;
    }
    public String getpostcode() {
         return postcode;
    }
    public String getemailaddress() {
         return emailaddress;
    }
    public String getmobilenumber() {
         return mobilenumber;
    }
    @Override
    public String toString() {
        return String.format("%d, %s , %s , %s , %s , %s , %s , %s, %s", this.customerID, this.firstname,this.lastname,this.streetaddress,this.suburb,this.state,this.postcode,this.emailaddress,this.mobilenumber);
    }


}
jpqldemo/src/main/java/com/tfth/jpqldemo/Demo.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Demo.java
package com.tfth.jpqldemo;
import javax.persistence.*;
import java.util.*;
public class Demo {

   public static void main(String args[]){
        Customer[] cust_arr = new Customer[10];
        Car[] car_arr = new Car[10];
        {
        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("TFTHPU");
        EntityManager em = emf.createEntityManager();
        for (int i = 0; i < 10; i++) {
            cust_arr[i] = new Customer(i,"FN"+i,"LN"+i,"test","test","test","test","test","test");
        }
        for (int i = 0; i < 5; i++) {
            car_arr[i] = new Echo(i,"ABC","Echo",2000,"test","auto",4,"blue",10000,true,true,true,true,true);
        }
        for (int i = 5; i < 10; i++) {
            car_arr[i] = new Liana(i,"ABC","Liana",2000,"test","auto",4,"blue",10000,true,true,true,true,true);
        }
        em.getTransaction().begin();
        for (int i = 0; i < 10; i++) {
            Sales s = new Sales(i,"05-06-2018",cust_arr[i],car_arr[i]);
            em.persist(s);
        }
        em.getTransaction().commit();

        //JPQL
        //Total number of customer records
        Query q1 = em.createQuery("SELECT COUNT(c) FROM Customer c");
        System.out.println("Total Customers: " + q1.getSingleResult());
        // Retrieve all the Sales objects from the database:
        TypedQuery query =
            em.createQuery("SELECT s FROM Sales s", Sales.class);
        List results = query.getResultList();
        for (Sales s : results) {
            System.out.println(s);
        }
        em.close();
        emf.close();
        }
   }

}
        //Query q1 = em.createQuery("SELECT COUNT(c) FROM Customer c");
        //System.out.println("Total Customers: " + q1.getSingleResult());

        // Retrieve all the Customer objects from the database:
        /*
        TypedQuery query =
            em.createQuery("SELECT c FROM Customer c", Customer.class);
        List results = query.getResultList();
        for (Customer c : results) {
            System.out.println(c);
        }
        */
jpqldemo/src/main/java/com/tfth/jpqldemo/Echo.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Echo.java
package com.tfth.jpqldemo;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@DiscriminatorValue(value="Ëcho")
public class Echo extends Car implements Serializable {
    private static final long serialVersionUID = 1L;

    //@Id
    //private long carID;
    private boolean inbuilt_navigator;
    private boolean audio;
    private boolean airconditioning;
    private boolean child_safety_lock;
    private boolean fog_lights;
    public Echo() {
    }
    Echo(long carID,String make, String model,long year_of_manufacture,String registration_number,String transmission_type,int number_of_seats,String colour,long price,boolean inbuilt_navigator,boolean audio,boolean airconditioning,boolean child_safety_lock,boolean fog_lights){
        super(carID,make,model,year_of_manufacture,registration_number,transmission_type,number_of_seats,colour,price);
        this.inbuilt_navigator=inbuilt_navigator;
        this.audio=audio;
        this.airconditioning=airconditioning;
        this.child_safety_lock=child_safety_lock;
        this.fog_lights=fog_lights;
    }
}
jpqldemo/src/main/java/com/tfth/jpqldemo/Liana.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Liana.java
package com.tfth.jpqldemo;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@DiscriminatorValue(value="Liana")
public class Liana extends Car implements Serializable {
    private static final long serialVersionUID = 1L;

    //@Id
    //private long carID;
    private boolean inbuilt_navigator;
    private boolean audio;
    private boolean airconditioning;
    private boolean child_safety_lock;
    private boolean fog_lights;
    public Liana() {
    }
    Liana(long carID,String make, String model,long year_of_manufacture,String registration_number,String transmission_type,int number_of_seats,String colour,long price,boolean inbuilt_navigator,boolean audio,boolean airconditioning,boolean child_safety_lock,boolean fog_lights){
        super(carID,make,model,year_of_manufacture,registration_number,transmission_type,number_of_seats,colour,price);
        this.inbuilt_navigator=inbuilt_navigator;
        this.audio=audio;
        this.airconditioning=airconditioning;
        this.child_safety_lock=child_safety_lock;
        this.fog_lights=fog_lights;
    }
}
jpqldemo/src/main/java/com/tfth/jpqldemo/Sales.java
jpqldemo/src/main/java/com/tfth/jpqldemo/Sales.java
package com.tfth.jpqldemo;
import java.io.Serializable;
import javax.persistence.*;
@Entity
public class Sales implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private long salesID;
    private String date;
    @ManyToOne(optional=false,cascade=CascadeType.PERSIST)
    @JoinColumn(name = "customerID")
    private Customer customer;
    @OneToOne(optional=false,cascade=CascadeType.PERSIST)
    @JoinColumn(name="carID")
    private Car car;
    public Sales() {
    }
    Sales(long salesID,String date,Customer cust,Car car) {
        this.salesID = salesID;
        this.date = date;
        this.customer=cust;//customerID;
        this.car = car;
    }
    public Long getsalesID() {
        return salesID;
    }
    public String getdate() {
         return date;
    }
    public Customer getCustomer() {
         return customer;
    }

    public Car getCar() {
         return car;
    }

    @Override
    public String toString() {
        return String.format("%d, %s, %d, %d", this.salesID, this.date, this.customer.getcustomerID(), this.car.getId());
    }
}
jpqldemo/src/main/resources/META-INF/persistence.xml


org.eclipse.persistence.jpa.PersistenceProvider
com.tfth.jpqldemo.Echo
com.tfth.jpqldemo.Liana
com.tfth.jpqldemo.Car
com.tfth.jpqldemo.Customer
com.tfth.jpqldemo.Sales










jpqldemo/target/classes/.netbeans_automatic_build
jpqldemo/target/classes/com/tfth/jpqldemo/Car.class
package com.tfth.jpqldemo;
public abstract synchronized class Car implements java.io.Serializable {
private static final long serialVersionUID = 1;
private long carID;
private String make;
private String model;
private long year_of_manufacture;
private String registration_number;
private String transmission_type;
private int number_of_seats;
private String colour;
private long price;
public void Car();
void Car(long, String, String, long, String, String, int, String, long);
public Long getId();
public String getMake();
public String getModel();
public String toString();
}
jpqldemo/target/classes/com/tfth/jpqldemo/Customer.class
package com.tfth.jpqldemo;
public synchronized class Customer implements java.io.Serializable {
private static final long serialVersionUID = 1;
private Long customerID;
private String firstname;
private String lastname;
private String streetaddress;
private String suburb;
private String state;
private String postcode;
private String emailaddress;
private String mobilenumber;
public void Customer();
void Customer(long, String, String, String, String, String, String, String, String);
public Long getcustomerID();
public String getfirstname();
public String getlastname();
public String getstreetaddress();
public String getsuburb();
public String getstate();
public String getpostcode();
public String getemailaddress();
public String getmobilenumber();
public String toString();
}
jpqldemo/target/classes/com/tfth/jpqldemo/Demo.class
package com.tfth.jpqldemo;
public synchronized class Demo {
public void Demo();
public static void main(String[]);
}
jpqldemo/target/classes/com/tfth/jpqldemo/Echo.class
package com.tfth.jpqldemo;
public synchronized class Echo extends Car implements java.io.Serializable {
private static final long serialVersionUID = 1;
private boolean inbuilt_navigator;
private boolean audio;
private boolean airconditioning;
private boolean child_safety_lock;
private boolean fog_lights;
public void Echo();
void Echo(long, String, String, long, String, String, int, String, long, boolean, boolean, boolean, boolean, boolean);
}
jpqldemo/target/classes/com/tfth/jpqldemo/Liana.class
package com.tfth.jpqldemo;
public synchronized class Liana extends Car implements java.io.Serializable {
private static final long serialVersionUID = 1;
private boolean inbuilt_navigator;
private boolean audio;
private boolean airconditioning;
private boolean child_safety_lock;
private boolean fog_lights;
public void Liana();
void Liana(long, String, String, long, String, String, int, String, long, boolean, boolean, boolean, boolean, boolean);
}
jpqldemo/target/classes/com/tfth/jpqldemo/one/Car_.class
package com.tfth.jpqldemo.one;
public abstract synchronized class Car_ {
public static volatile javax.persistence.metamodel.SingularAttribute colour;
public static volatile javax.persistence.metamodel.SingularAttribute registration_number;
public static volatile javax.persistence.metamodel.SingularAttribute price;
public static volatile javax.persistence.metamodel.SingularAttribute model;
public static volatile javax.persistence.metamodel.SingularAttribute year_of_manufacture;
public static volatile javax.persistence.metamodel.SingularAttribute make;
public static volatile javax.persistence.metamodel.SingularAttribute transmission_type;
public static volatile javax.persistence.metamodel.SingularAttribute number_of_seats;
public static volatile javax.persistence.metamodel.SingularAttribute carID;
public void Car_();
}
jpqldemo/target/classes/com/tfth/jpqldemo/one/Customer_.class
package com.tfth.jpqldemo.one;
public synchronized class Customer_ {
public static volatile javax.persistence.metamodel.SingularAttribute firstname;
public static volatile javax.persistence.metamodel.SingularAttribute mobilenumber;
public static volatile javax.persistence.metamodel.SingularAttribute...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here