Assignment 4 - Choice C - Automatic Generation of DAO implementations

This is one of the choices for Assignment 4 The goal of this assignment choice is to understand the DAO pattern and methods for automatic generation of DAO implementations.

Deadlines: This assignment puts together 2 lab sessions (corresponding weeks 11 and 12) and contains up to two Bonus point. Results should be presented no later than week 14.

General grading policy: Grades reflect your individual knowledge and contribution. Each student must complete and present their own solutions. The solutions developed "in group" or copied will be assigned 0(zero) points. Not presenting the assignment is assigned 4 points.

Problem description

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 could be automatically generated by tools.

References

Design and implement a (part of) a very simplified DAO generator. The user of the DAO generator tool must provide as input:

Implement a DAO generator as described above. 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 execures 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:

This assignment contains one exam bonus point in the initial requirements stated above.

Further extension (a second bonus point): eliminate some of the restrictions relative to the allowed forms of Java classes accepted. Accept classes that may have associations with other classes. Assume a default pattern of mapping classes to tables (for associations). 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.