Assignment 4: Technologies and Patterns for Data Access

This is one of the choices for Assignment 4.

The Data Access Object (DAO) Pattern

Objectives: This assignment focuses on DAO pattern, understanding the DAO pattern and methods for automatic generation of DAO implementations. As a conceptual background, all concepts related to data access technologies of different levels of abstraction and data access patterns must be known (Lectures weeks 9,10,11).

Assignment 4 variant: Automatic Generation of DAO Implementation

Stanndard Requirements

The goal of the DAOpattern is to abstract and encapsulate all access to the data source by introducing a DAO interface.

The implementation of such a DAO interface will always contain some boilerplate code, thus it can be automatically generated by tools. There are frameworks such as Spring Data which are doing this.

For this asssignment, design and implement a (part of) a very simplified DAO generator.

Your DAO generator tool will take as input:

Implement a DAO generator for the conditions described before. The implementation of any method with a name following the pattern findBy[attribute], having one argument attributevalue, will use a JDBC connection to the database and execute a query such as SELECT * WHERE ATTRIBUTE=ATTRIBUTEVALUE. The DAO Generator parses the method names and constructs the corresponding queries and executes them. All the query methods return lists of datatransfer objects (no ResultSets are returned !) To generate the DAOImplementation class you can use any one of the following 2 strategies (similar with generating clientside proxies for broker):

Demonstrate the use of your DAO generator in 2 different applications:

Bonus Requirements

Further extension: eliminate some of the restrictions relative to the allowed forms of Java classes accepted. Accept classes that may have association relationships with other classes. Methods in the DAO interface can include find methods that refer to attributes of associated classes using the dot notation. For example, class Order has an attribute of type Customer. You can define in the DAO interface handling Orders a method such as findByCustomerName(aName). The same query method can use values for its own attributes and attributes of associated classes, such as findByCustomerNameAndDate(aName, aDate): Date is an attribute of Order, Order is associated with Customer and Customer has an attribute Name.

Deadlines and Grading

The deadline for this assignment is in Week 13. See the Grading Policy on CV for PASSC and DACSS.

Frameworks/technologies to use

Resources