Jelly Beans 1: Mock Persistence
This Jelly Beans series deals with data entities, as required for the Gooey Beans series' demos. Together with Hyper Beans, i'm calling them the Foundation Trilogy :) And yes, it's a scifi/fantasy trilogy in 42 parts, essentially about writing database applications using Swing.
So we create our "database" as an in-memory-only object graph, which is populated with test data when we startup our app. That is, we "save" our entity beans in a TreeMap, without actually persisting them to a database. For GUI prototyping and demos, this is not as useless as it sounds ;)
Click here to read "Mock Persistence"
The debut of the "Jelly Beans" data survival series
We create (and delete et al) test data for the Person Info
demo used in the sibling Gooey Beans series.
We create test data at startup as follows.
where entityManager declares our "entity info" objects eg. DPersonInfo,
which serve as "data access objects" eg. for DPerson entities.
Demo
(PersonInfo, 150k/500k, unsandboxed, Java6)
Code Snippet
public class ContactTestData {
...
DPerson jackSparrow =
createPerson("jsparrow", "Jack Sparrow", "captjs@blackpearl");
...
DCountry jamaicaCountry =
createCountry("jm", "Jamaica", "jm", 1876, jmd);
...
DRegion portRoyalRegion =
createCityRegion(jamaicaRegion, "Port Royal");
...
protected DPerson createPerson(String personId, String personName,
String emailAddress) {
DPerson person = new DPerson();
person.setPersonId(personId);
...
entityManager.personInfo.save(person);
return person;
}
...
}





