Assignment # 11
Project
This assignment is part of Project#1.
Learning Goals
- Understand how to use the Java Persistence API to interface your Java code with a DB.
Assignment
- Modify your Project 1 code so that you persist the Mets data in yoru Java Bean to a DB.
- Define the entities that will hold the data (e.g., name and address) .
- Each valid set of form data will constitute an entity instance.
- Create annotated classes corresponding to your entities.
- Do not allow duplicate registration, but allow a user to update the registration information previously provided.
Hints:
- Be sure to use the Glassfish application server. We have not tested the Persistence API with TomCat.
- There is a code example within NetBeans that may be helpful.
- You can use any database to which you have access.
- If you don't have easy access to a database that supports Java Persistence, you can use the Derby database. This is provided by Sun, and
is packaged within NetBeans. MySQL is also packaged by NetBeans (since early in May 2008).
- Your object design of the Mets form data can include only one entity (the bean).
- You can use any reasonable approach to discover duplicates (e.g., compare first name and last name).
- You may have some problems in using persistence within a servlet. Web applications support container based persistence and application
based persistence; you should use application based persistence, since it closely resembles the code we covered in class. If you are having
problems with the persistence.xml file, you can build this assignment as an application. Just find some way to input the form data to your
application and generate limited output using System console output.