Hello World, With Buddies, Buddy Ages and of course Lazy Loading and Identity Map
Setup Tomcat and Eclipse:
Start where you left off with your solution from the Hello World with Updates previous tutorial
Start Eclipse:
eclipse_luna
Use your previous project:
Server should already be set up:
Proxies
- The first step is to extract an Interface from your person. Eclipse will do this for you if you right-click in the class, and choose "Extract Interface"
- IPerson is the conventional name for the interface of Person, and leave it in the same folder (which is maybe org.soen387.tutorial.dom.model.person if you're thinking ahead)
- Now you need to create a Proxy that inherits from IPerson and has an id, innerPerson and getInnerObject method
- Look at the notes and talk amongst yourselves to figure out thre rest of the details... but it involves calling the mapper.
- Note: You have to decide what to do about Exceptions!!!
Identity Map
- As discussed in class, each Data Mapper should have a ThreadLocal Identity Map Associated With it
- Your map can just be a HashMap
- Make sure to check for all ids in the map before creating a Person
- If you do create a Person in the Mapper, remember to add it to the Identity Map
Adding Buddies and Age
- If you read through the tutorial before starting and see this, and like a bit of suffering, try to do this step BEFORE you add Identity Map and Lazy Loading
- Your list of people should now be in a table
-
- Columns should be, name, age, buddy name, budy age, edit, delete
- The delete button should remove that person, as normal
- the edit button should take you to a page where you can edit first and last name, age and choose a buddy from a dropdown.
- Make sure the dropdown includes a blank field for having no buddy and allows a person to choose themselves as buddy, have a save button that takes you back to the list.
- Keep the add person fields/button as normal, but add an age column and a buddy dropdown as per the above.
Note:
You still need that ssh tunnel or a local database. The databse table is the same as from the previous tutorial
Solution:
A solution.