You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ie...@apache.org on 2008/09/15 14:24:19 UTC

svn commit: r695451 [2/2] - in /incubator/shindig/trunk/java/samples: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/shindig/ src/main/java/org/apache/shindig/social/ src/main/java/org/apache/shin...

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,1181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import static javax.persistence.GenerationType.IDENTITY;
+
+import org.apache.shindig.social.opensocial.model.Account;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.BodyType;
+import org.apache.shindig.social.opensocial.model.Enum;
+import org.apache.shindig.social.opensocial.model.ListField;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.Organization;
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Url;
+import org.apache.shindig.social.opensocial.model.Enum.Drinker;
+import org.apache.shindig.social.opensocial.model.Enum.LookingFor;
+import org.apache.shindig.social.opensocial.model.Enum.NetworkPresence;
+import org.apache.shindig.social.opensocial.model.Enum.Smoker;
+
+import com.google.common.collect.Lists;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import static javax.persistence.CascadeType.ALL;
+import static javax.persistence.CascadeType.PERSIST;
+import static javax.persistence.CascadeType.REFRESH;
+import static javax.persistence.CascadeType.MERGE;
+
+/**
+ * Default Implementation of the Person object in the org.apache.shindig.social.opensocial.jpa.
+ */
+@Entity
+@Table(name = "person")
+@NamedQueries(value = {
+    @NamedQuery(name = PersonDb.FINDBY_PERSONID, query = "select p from PersonDb p where p.id = :id "),
+    @NamedQuery(name = PersonDb.FINDBY_LIKE_PERSONID, query = "select p from PersonDb p where p.id like :id") })
+public class PersonDb implements Person, DbObject {
+
+  public static final String FINDBY_PERSONID = "q.person.findbypersonid";
+
+  public static final String PARAM_PERSONID = "id";
+
+  public static final String FINDBY_LIKE_PERSONID = "q.person.findbylikepersonid";
+
+  private static final String LOOKING_FOR_PROPERTY = "looking-for";
+
+  private static final String ACTIVITIES_PROPERTY = "activity";
+
+  private static final String BOOKS_PROPERTY = "book";
+
+  private static final String CARS_PROPERTY = "car";
+
+  private static final String HEROES_PROPERTY = "hero";
+
+  private static final String INTERESTS_PROPERTY = "interest";
+
+  private static final String LANGUAGES_PROPERTY = "language";
+
+  private static final String MOVIES_PROPERTY = "movie";
+
+  private static final String MUSIC_PROPERTY = "music";
+
+  private static final String FOOD_PROPERTY = "food";
+
+  private static final String QUOTES_PROPERTY = "quotes";
+
+  private static final String SPORTS_PROPERTY = "sport";
+
+  private static final String TAGS_PROPERTY = "tag";
+
+  private static final String TURNOFFS_PROPERTY = "turnoff";
+
+  private static final String TURNONS_PROPERTY = "turnon";
+
+  private static final String TVSHOWS_PROPERTY = "tvshow";
+
+  @Id
+  @GeneratedValue(strategy = IDENTITY)
+  @Column(name = "oid")
+  private long objectId;
+
+  @Version
+  @Column(name = "version")
+  protected long version;
+
+  @Basic
+  @Column(name = "about_me", length = 255)
+  protected String aboutMe;
+
+  @OneToMany(targetEntity = PersonPropertiesDb.class, mappedBy = "person", cascade = ALL)
+  protected List<PersonPropertiesDb> properties = new ArrayList<PersonPropertiesDb>();
+
+  @OneToMany(targetEntity = PersonAccountDb.class, mappedBy = "person", cascade = ALL)
+  protected List<Account> accounts;
+
+  @Transient
+  protected List<String> activities;
+
+  @OneToMany(targetEntity = PersonAddressDb.class, mappedBy = "person", cascade = ALL)
+  protected List<Address> addresses;
+
+  @Basic
+  @Column(name = "age")
+  protected Integer age;
+
+  @ManyToOne(targetEntity = BodyTypeDb.class, cascade = ALL)
+  @JoinColumn(name = "body_type_id", referencedColumnName = "oid")
+  protected BodyType bodyType;
+
+  @Transient
+  protected List<String> books;
+
+  @Transient
+  protected List<String> cars;
+
+  @Basic
+  @Column(name = "children", length = 255)
+  protected String children;
+
+  /**
+   * 
+   */
+  @ManyToOne(targetEntity = AddressDb.class, cascade = { PERSIST, MERGE, REFRESH })
+  @JoinColumn(name = "address_id", referencedColumnName = "oid")
+  protected Address currentLocation;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "birthday")
+  @Temporal(TemporalType.DATE)
+  protected Date birthday;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "drinker", length = 255)
+  protected String drinkerDb;
+
+  @Transient
+  protected Enum<Enum.Drinker> drinker;
+
+  
+  @Basic
+  @Column(name = "display_name", length = 255)
+  private String displayName;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = EmailDb.class, mappedBy = "person", cascade= ALL)
+  protected List<ListField> emails;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "ethnicity", length = 255)
+  protected String ethnicity;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "fashion", length = 255)
+  protected String fashion;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> food;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "gender", length = 255)
+  protected String genderDb;
+
+  @Transient
+  protected Gender gender;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "happiest_when", length = 255)
+  protected String happiestWhen;
+
+  /**
+   * 
+   */
+  @Transient
+  protected Boolean hasApp;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> heroes;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "humor", length = 255)
+  protected String humor;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "person_id", length = 255)
+  protected String id;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = ImDb.class, mappedBy = "person", cascade = ALL)
+  protected List<ListField> ims;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> interests;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "job_interests", length = 255)
+  protected String jobInterests;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> languagesSpoken;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "updated")
+  @Temporal(TemporalType.TIMESTAMP)
+  protected Date updated;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "living_arrangement", length = 255)
+  protected String livingArrangement;
+
+  /**
+   * 
+   */
+  @Transient
+  // stored as a property, processed on get,set
+  protected List<Enum<Enum.LookingFor>> lookingFor;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> movies;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> music;
+
+  /**
+   * 
+   */
+  @ManyToOne(targetEntity = NameDb.class, cascade = ALL)
+  @JoinColumn(name = "name_id", referencedColumnName = "oid")
+  protected Name name;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "network_presence", length = 255)
+  protected String networkPresenceDb;
+
+  @Transient
+  protected Enum<Enum.NetworkPresence> networkPresence = new EnumDb<NetworkPresence>(NetworkPresence.XA);
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "nickname", length = 255)
+  protected String nickname;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = PersonOrganizationDb.class, mappedBy = "person", cascade = { PERSIST, MERGE, REFRESH })
+  protected List<Organization> organizations;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "pets", length = 255)
+  protected String pets;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = PhoneDb.class, mappedBy = "person", cascade = ALL)
+  protected List<ListField> phoneNumbers;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = PhotoDb.class, mappedBy = "person", cascade = ALL)
+  protected List<ListField> photos;
+  @Basic
+  @Column(name = "political_views", length = 255)
+  protected String politicalViews;
+
+  /**
+   * 
+   */
+  @Transient
+  protected Url profileSong;
+
+  /**
+   * 
+   */
+  @Transient
+  protected Url profileVideo;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> quotes;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "relationship_status", length = 255)
+  protected String relationshipStatus;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "religion", length = 255)
+  protected String religion;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "romance", length = 255)
+  protected String romance;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "scared_of", length = 255)
+  protected String scaredOf;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "sexual_orientation", length = 255)
+  protected String sexualOrientation;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "smoker", length = 255)
+  protected String smokerDb;
+
+  @Transient
+  protected Enum<Enum.Smoker> smoker;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> sports;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "status", length = 255)
+  protected String status;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> tags;
+
+  /**
+   * 
+   */
+  @Basic
+  @Column(name = "utc_offset")
+  protected Long utcOffset;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> turnOffs;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> turnOns;
+
+  /**
+   * 
+   */
+  @Transient
+  protected List<String> tvShows;
+
+  /**
+   * 
+   */
+  @OneToMany(targetEntity = UrlDb.class, mappedBy = "person", cascade = ALL)
+  protected List<Url> urls;
+
+  // Note: Not in the opensocial js person object directly
+  @Transient
+  private boolean isOwner = false;
+
+  @Transient
+  private boolean isViewer = false;
+
+
+  public PersonDb() {
+  }
+
+  public PersonDb(String id, String displayName , Name name) {
+    this.id = id;
+    this.name = name;
+    this.displayName = displayName;
+  }
+
+  public String getAboutMe() {
+    return aboutMe;
+  }
+
+  public void setAboutMe(String aboutMe) {
+    this.aboutMe = aboutMe;
+  }
+
+  public List<Account> getAccounts() {
+    return accounts;
+  }
+
+  public void setAccounts(List<Account> accounts) {
+    this.accounts = accounts;
+  }
+
+  public List<String> getActivities() {
+    return activities;
+  }
+
+  public void setActivities(List<String> activities) {
+    this.activities = activities;
+  }
+
+  public List<Address> getAddresses() {
+    return addresses;
+  }
+
+  public void setAddresses(List<Address> addresses) {
+    this.addresses = addresses;
+  }
+
+  public Integer getAge() {
+    return age;
+  }
+
+  public void setAge(Integer age) {
+    this.age = age;
+  }
+
+  public BodyType getBodyType() {
+    return bodyType;
+  }
+
+  public void setBodyType(BodyType bodyType) {
+    this.bodyType = bodyType;
+  }
+
+  public List<String> getBooks() {
+    return books;
+  }
+
+  public void setBooks(List<String> books) {
+    this.books = books;
+  }
+
+  public List<String> getCars() {
+    return cars;
+  }
+
+  public void setCars(List<String> cars) {
+    this.cars = cars;
+  }
+
+  public String getChildren() {
+    return children;
+  }
+
+  public void setChildren(String children) {
+    this.children = children;
+  }
+
+  public Address getCurrentLocation() {
+    return currentLocation;
+  }
+
+  public void setCurrentLocation(Address currentLocation) {
+    this.currentLocation = currentLocation;
+  }
+
+  public Date getBirthday() {
+    if (birthday == null) {
+      return null;
+    }
+    return new Date(birthday.getTime());
+  }
+
+  public void setBirthday(Date birthday) {
+    if (birthday == null) {
+      this.birthday = null;
+    } else {
+      this.birthday = new Date(birthday.getTime());
+    }
+  }
+
+  public Enum<Enum.Drinker> getDrinker() {
+    return this.drinker;
+  }
+
+  public void setDrinker(Enum<Enum.Drinker> newDrinker) {
+    this.drinker = newDrinker;
+  }
+
+  public List<ListField> getEmails() {
+    return emails;
+  }
+
+  public void setEmails(List<ListField> emails) {
+    this.emails = emails;
+  }
+
+  public String getEthnicity() {
+    return ethnicity;
+  }
+
+  public void setEthnicity(String ethnicity) {
+    this.ethnicity = ethnicity;
+  }
+
+  public String getFashion() {
+    return fashion;
+  }
+
+  public void setFashion(String fashion) {
+    this.fashion = fashion;
+  }
+
+  public List<String> getFood() {
+    return food;
+  }
+
+  public void setFood(List<String> food) {
+    this.food = food;
+  }
+
+  public Gender getGender() {
+    return gender;
+  }
+
+  public void setGender(Gender newGender) {
+    this.gender = newGender;
+  }
+
+  public String getHappiestWhen() {
+    return happiestWhen;
+  }
+
+  public void setHappiestWhen(String happiestWhen) {
+    this.happiestWhen = happiestWhen;
+  }
+
+  public Boolean getHasApp() {
+    return hasApp;
+  }
+
+  public void setHasApp(Boolean hasApp) {
+    this.hasApp = hasApp;
+  }
+
+  public List<String> getHeroes() {
+    return heroes;
+  }
+
+  public void setHeroes(List<String> heroes) {
+    this.heroes = heroes;
+  }
+
+  public String getHumor() {
+    return humor;
+  }
+
+  public void setHumor(String humor) {
+    this.humor = humor;
+  }
+
+  public String getId() {
+    return id;
+  }
+
+  public void setId(String id) {
+    this.id = id;
+  }
+
+  public List<ListField> getIms() {
+    return ims;
+  }
+
+  public void setIms(List<ListField> ims) {
+    this.ims = ims;
+  }
+
+  public List<String> getInterests() {
+    return interests;
+  }
+
+  public void setInterests(List<String> interests) {
+    this.interests = interests;
+  }
+
+  public String getJobInterests() {
+    return jobInterests;
+  }
+
+  public void setJobInterests(String jobInterests) {
+    this.jobInterests = jobInterests;
+  }
+
+  public List<String> getLanguagesSpoken() {
+    return languagesSpoken;
+  }
+
+  public void setLanguagesSpoken(List<String> languagesSpoken) {
+    this.languagesSpoken = languagesSpoken;
+  }
+
+  public Date getUpdated() {
+    if (updated == null) {
+      return null;
+    }
+    return new Date(updated.getTime());
+  }
+
+  public void setUpdated(Date updated) {
+    if (updated == null) {
+      this.updated = null;
+    } else {
+      this.updated = new Date(updated.getTime());
+    }
+  }
+
+  public String getLivingArrangement() {
+    return livingArrangement;
+  }
+
+  public void setLivingArrangement(String livingArrangement) {
+    this.livingArrangement = livingArrangement;
+  }
+
+  public List<Enum<Enum.LookingFor>> getLookingFor() {
+    return lookingFor;
+  }
+
+  public void setLookingFor(List<Enum<Enum.LookingFor>> lookingFor) {
+    this.lookingFor = lookingFor;
+  }
+
+  public List<String> getMovies() {
+    return movies;
+  }
+
+  public void setMovies(List<String> movies) {
+    this.movies = movies;
+  }
+
+  public List<String> getMusic() {
+    return music;
+  }
+
+  public void setMusic(List<String> music) {
+    this.music = music;
+  }
+
+  public Name getName() {
+    return name;
+  }
+
+  public void setName(Name name) {
+    this.name = name;
+  }
+
+  public Enum<Enum.NetworkPresence> getNetworkPresence() {
+    return networkPresence;
+  }
+
+  public void setNetworkPresence(Enum<Enum.NetworkPresence> networkPresence) {
+    this.networkPresence = networkPresence;
+  }
+
+  public String getNickname() {
+    return nickname;
+  }
+
+  public void setNickname(String nickname) {
+    this.nickname = nickname;
+  }
+
+  public List<Organization> getOrganizations() {
+    return organizations;
+  }
+
+  public void setOrganizations(List<Organization> organizations) {
+    this.organizations = organizations;
+  }
+
+  public String getPets() {
+    return pets;
+  }
+
+  public void setPets(String pets) {
+    this.pets = pets;
+  }
+
+  public List<ListField> getPhoneNumbers() {
+    return phoneNumbers;
+  }
+
+  public void setPhoneNumbers(List<ListField> phoneNumbers) {
+    this.phoneNumbers = phoneNumbers;
+  }
+
+  public List<ListField> getPhotos() {
+    return photos;
+  }
+
+  public void setPhotos(List<ListField> photos) {
+    this.photos = photos;
+  }
+
+  public String getPoliticalViews() {
+    return politicalViews;
+  }
+
+  public void setPoliticalViews(String politicalViews) {
+    this.politicalViews = politicalViews;
+  }
+
+  public Url getProfileSong() {
+    return profileSong;
+  }
+
+  public void setProfileSong(Url profileSong) {
+    this.profileSong = profileSong;
+  }
+
+  public Url getProfileVideo() {
+    return profileVideo;
+  }
+
+  public void setProfileVideo(Url profileVideo) {
+    this.profileVideo = profileVideo;
+  }
+
+  public List<String> getQuotes() {
+    return quotes;
+  }
+
+  public void setQuotes(List<String> quotes) {
+    this.quotes = quotes;
+  }
+
+  public String getRelationshipStatus() {
+    return relationshipStatus;
+  }
+
+  public void setRelationshipStatus(String relationshipStatus) {
+    this.relationshipStatus = relationshipStatus;
+  }
+
+  public String getReligion() {
+    return religion;
+  }
+
+  public void setReligion(String religion) {
+    this.religion = religion;
+  }
+
+  public String getRomance() {
+    return romance;
+  }
+
+  public void setRomance(String romance) {
+    this.romance = romance;
+  }
+
+  public String getScaredOf() {
+    return scaredOf;
+  }
+
+  public void setScaredOf(String scaredOf) {
+    this.scaredOf = scaredOf;
+  }
+
+  public String getSexualOrientation() {
+    return sexualOrientation;
+  }
+
+  public void setSexualOrientation(String sexualOrientation) {
+    this.sexualOrientation = sexualOrientation;
+  }
+
+  public Enum<Enum.Smoker> getSmoker() {
+    return this.smoker;
+  }
+
+  public void setSmoker(Enum<Enum.Smoker> newSmoker) {
+    this.smoker = newSmoker;
+  }
+
+  public List<String> getSports() {
+    return sports;
+  }
+
+  public void setSports(List<String> sports) {
+    this.sports = sports;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public List<String> getTags() {
+    return tags;
+  }
+
+  public void setTags(List<String> tags) {
+    this.tags = tags;
+  }
+
+  public Long getUtcOffset() {
+    return utcOffset;
+  }
+
+  public void setUtcOffset(Long utcOffset) {
+    this.utcOffset = utcOffset;
+  }
+
+  public List<String> getTurnOffs() {
+    return turnOffs;
+  }
+
+  public void setTurnOffs(List<String> turnOffs) {
+    this.turnOffs = turnOffs;
+  }
+
+  public List<String> getTurnOns() {
+    return turnOns;
+  }
+
+  public void setTurnOns(List<String> turnOns) {
+    this.turnOns = turnOns;
+  }
+
+  public List<String> getTvShows() {
+    return tvShows;
+  }
+
+  public void setTvShows(List<String> tvShows) {
+    this.tvShows = tvShows;
+  }
+
+  public List<Url> getUrls() {
+    return urls;
+  }
+
+  public void setUrls(List<Url> urls) {
+    this.urls = urls;
+  }
+
+  public boolean getIsOwner() {
+    return isOwner;
+  }
+
+  public void setIsOwner(boolean isOwner) {
+    this.isOwner = isOwner;
+  }
+
+  public boolean getIsViewer() {
+    return isViewer;
+  }
+
+  public void setIsViewer(boolean isViewer) {
+    this.isViewer = isViewer;
+  }
+
+  // Proxied fields
+
+  public String getProfileUrl() {
+    Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
+    return url == null ? null : url.getValue();
+  }
+
+  public void setProfileUrl(String profileUrl) {
+    Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
+    if (url != null) {
+      url.setValue(profileUrl);
+    } else {
+      setUrls(addListField(new UrlDb(profileUrl, null, PROFILE_URL_TYPE), getUrls()));
+    }
+  }
+
+  public String getThumbnailUrl() {
+    ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
+    return photo == null ? null : photo.getValue();
+  }
+
+  public void setThumbnailUrl(String thumbnailUrl) {
+    ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
+    if (photo != null) {
+      photo.setValue(thumbnailUrl);
+    } else {
+      setPhotos(addListField(new ListFieldDb(THUMBNAIL_PHOTO_TYPE, thumbnailUrl), getPhotos()));
+    }
+  }
+
+  private <T extends ListField> T getListFieldWithType(String type, List<T> list) {
+    if (list != null) {
+      for (T url : list) {
+        if (type.equalsIgnoreCase(url.getType())) {
+          return url;
+        }
+      }
+    }
+
+    return null;
+  }
+
+  private <T extends ListField> List<T> addListField(T field, List<T> list) {
+    if (list == null) {
+      list = Lists.newArrayList();
+    }
+    list.add(field);
+    return list;
+  }
+
+  /**
+   * @return the objectId
+   */
+  public long getObjectId() {
+    return objectId;
+  }
+
+  /**
+   * @param objectId the objectId to set
+   */
+  public void setObjectId(long objectId) {
+    this.objectId = objectId;
+  }
+
+  @PrePersist
+  public void populateDbFields() {
+    drinkerDb = drinker.toString();
+    genderDb = gender.toString();
+    networkPresenceDb = networkPresence.toString();
+    smokerDb = smoker.toString();
+
+    List<String> lookingFor = new ArrayList<String>();
+    for (Enum<Enum.LookingFor> np : this.lookingFor) {
+      lookingFor.add(np.toString());
+    }
+    Map<String, List<String>> toSave = new HashMap<String, List<String>>();
+    toSave.put(LOOKING_FOR_PROPERTY, lookingFor);
+    toSave.put(ACTIVITIES_PROPERTY, this.activities);
+    toSave.put(BOOKS_PROPERTY, this.books);
+    toSave.put(CARS_PROPERTY, this.cars);
+    toSave.put(FOOD_PROPERTY, this.food);
+    toSave.put(HEROES_PROPERTY, this.heroes);
+    toSave.put(INTERESTS_PROPERTY, this.interests);
+    toSave.put(LANGUAGES_PROPERTY, this.languagesSpoken);
+    toSave.put(MOVIES_PROPERTY, this.movies);
+    toSave.put(MUSIC_PROPERTY, this.music);
+    toSave.put(QUOTES_PROPERTY, this.quotes);
+    toSave.put(SPORTS_PROPERTY, this.sports);
+    toSave.put(TAGS_PROPERTY, this.tags);
+    toSave.put(TURNOFFS_PROPERTY, this.turnOffs);
+    toSave.put(TURNONS_PROPERTY, this.turnOns);
+    toSave.put(TVSHOWS_PROPERTY, this.tvShows);
+
+    for (Entry<String, List<String>> e : toSave.entrySet()) {
+      // add new entries
+      for (String v : e.getValue()) {
+        boolean present = false;
+        for (PersonPropertiesDb pp : properties) {
+          if (e.getKey().equals(pp.getType()) && v.equals(pp.getValue())) {
+            present = true;
+            break;
+          }
+        }
+        if (!present) {
+          PersonPropertiesDb pp = new PersonPropertiesDb();
+          pp.setType(e.getKey());
+          pp.setValue(v);
+        }
+      }
+      // remove missing entries
+      List<PersonPropertiesDb> toRemove = new ArrayList<PersonPropertiesDb>();
+      for (PersonPropertiesDb pp : properties) {
+        if (e.getKey().equals(pp.getType())) {
+          boolean present = false;
+          for (String v : e.getValue()) {
+            if (pp.getValue().equals(v)) {
+              present = true;
+              break;
+            }
+          }
+          if (!present) {
+            toRemove.add(pp);
+          }
+        }
+      }
+      properties.removeAll(toRemove);
+    }
+  }
+
+  @PostLoad
+  public void loadTransientFields() {
+
+    drinkerDb = drinker.toString();
+    genderDb = gender.toString();
+    networkPresenceDb = networkPresence.toString();
+    smokerDb = smoker.toString();
+
+    drinker = new EnumDb<Drinker>(Drinker.valueOf(drinkerDb));
+    gender = Gender.valueOf(genderDb);
+    networkPresence = new EnumDb<NetworkPresence>(NetworkPresence.valueOf(networkPresenceDb));
+    smoker = new EnumDb<Smoker>(Smoker.valueOf(smokerDb));
+
+    List<String> lookingFor = new ArrayList<String>();
+    this.activities = new ArrayList<String>();
+    this.books = new ArrayList<String>();
+    this.cars = new ArrayList<String>();
+    this.food = new ArrayList<String>();
+    this.heroes = new ArrayList<String>();
+    this.interests = new ArrayList<String>();
+    this.languagesSpoken = new ArrayList<String>();
+    this.movies = new ArrayList<String>();
+    this.music = new ArrayList<String>();
+    this.quotes = new ArrayList<String>();
+    this.sports = new ArrayList<String>();
+    this.tags = new ArrayList<String>();
+    this.turnOffs = new ArrayList<String>();
+    this.turnOns = new ArrayList<String>();
+    this.tvShows = new ArrayList<String>();
+
+    Map<String, List<String>> toSave = new HashMap<String, List<String>>();
+
+    toSave.put(LOOKING_FOR_PROPERTY, lookingFor);
+    toSave.put(ACTIVITIES_PROPERTY, this.activities);
+    toSave.put(BOOKS_PROPERTY, this.books);
+    toSave.put(CARS_PROPERTY, this.cars);
+    toSave.put(FOOD_PROPERTY, this.food);
+    toSave.put(HEROES_PROPERTY, this.heroes);
+    toSave.put(INTERESTS_PROPERTY, this.interests);
+    toSave.put(LANGUAGES_PROPERTY, this.languagesSpoken);
+    toSave.put(MOVIES_PROPERTY, this.movies);
+    toSave.put(MUSIC_PROPERTY, this.music);
+    toSave.put(QUOTES_PROPERTY, this.quotes);
+    toSave.put(SPORTS_PROPERTY, this.sports);
+    toSave.put(TAGS_PROPERTY, this.tags);
+    toSave.put(TURNOFFS_PROPERTY, this.turnOffs);
+    toSave.put(TURNONS_PROPERTY, this.turnOns);
+    toSave.put(TVSHOWS_PROPERTY, this.tvShows);
+
+    for (PersonPropertiesDb pp : properties) {
+      List<String> l = toSave.get(pp.type);
+      if (l != null) {
+        l.add(pp.getValue());
+      }
+    }
+
+    this.lookingFor = new ArrayList<Enum<LookingFor>>();
+    for (String lf : lookingFor) {
+      this.lookingFor.add(new EnumDb<LookingFor>(LookingFor.valueOf(lf)));
+    }
+
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.shindig.social.opensocial.model.Person#getDisplayName()
+   */
+  public String getDisplayName() {
+    return displayName;
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.shindig.social.opensocial.model.Person#setDisplayName(java.lang.String)
+   */
+  public void setDisplayName(String displayName) {
+    this.displayName = displayName;    
+  }
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonOrganizationDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ *
+ */
+/*
+ * This object connects to a single Address, and to a single organization, 
+ * defining the organizations relationship with the address
+ */
+@Entity
+@Table(name="person_organization")
+@DiscriminatorValue("shared")
+@NamedQuery(name=PersonOrganizationDb.PERSON_ORG_FINDBY_NAME,query="select p from PersonOrganizationDb p where p.name = :name ")
+public class PersonOrganizationDb extends OrganizationDb {
+  public static final String PERSON_ORG_FINDBY_NAME = "q.personorganizationdb.findbyname";
+
+  @Basic
+  @Column(name="primary_organization", table="person_organization")
+  private Boolean primary;
+  
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+  
+  @Basic
+  @Column(name="type", length=255, table="person_organization")
+  private String type;
+
+
+  public PersonOrganizationDb() {
+    // TODO Auto-generated constructor stub
+  }
+
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+
+  public Boolean getPrimary() {
+    return primary;
+  }
+
+  public void setPrimary(Boolean primary) {
+    this.primary = primary;
+  }
+
+
+
+
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertiesDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertiesDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertiesDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PersonPropertiesDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ *
+ */
+@Entity
+@Table(name="person_properties")
+@PrimaryKeyJoinColumn(name="oid")
+public class PersonPropertiesDb extends ListFieldDb {
+
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhoneDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ *
+ */
+@Entity
+@Table(name="phone")
+@PrimaryKeyJoinColumn(name="oid")
+@NamedQuery(name=PhoneDb.FINDBY_PHONE_NUMBER,query="select p from PhoneDb p where p.value = :phonenumber ")
+public class PhoneDb extends ListFieldDb {
+
+  public static final String FINDBY_PHONE_NUMBER = "q.pphone.findbynumber";
+  public static final String PARAM_PHONE_NUMBER = "phonenumber";
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/PhotoDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ *
+ */
+@Entity
+@Table(name="photo")
+@PrimaryKeyJoinColumn(name="oid")
+public class PhotoDb extends ListFieldDb {
+
+  @ManyToOne(targetEntity=PersonDb.class)
+  @JoinColumn(name="person_id", referencedColumnName="oid")
+  protected Person person;
+
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/UrlDb.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa;
+
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Url;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+/**
+ * see http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Url.Field.html
+ */
+@Entity
+@Table(name = "url")
+@PrimaryKeyJoinColumn(name = "oid")
+@NamedQuery(name = UrlDb.FINDBY_URL, query = "select u from UrlDb u where u.value = :url ")
+public class UrlDb extends ListFieldDb implements Url {
+  public static final String FINDBY_URL = "q.url.findbyurl";
+
+  public static final String PARAM_URL = "url";
+
+  @Basic
+  @Column(name = "link_text")
+  private String linkText;
+
+  @ManyToOne(targetEntity = PersonDb.class)
+  @JoinColumn(name = "person_id", referencedColumnName = "oid")
+  protected Person person;
+
+  public UrlDb() {
+  }
+
+  public UrlDb(String value, String linkText, String type) {
+    super(type, value);
+    this.linkText = linkText;
+  }
+
+  public String getLinkText() {
+    return linkText;
+  }
+
+  public void setLinkText(String linkText) {
+    this.linkText = linkText;
+  }
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/Bootstrap.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/Bootstrap.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/Bootstrap.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/Bootstrap.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa.eclipselink;
+
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_LEVEL;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_SESSION;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_THREAD;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_TIMESTAMP;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.TARGET_SERVER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.TRANSACTION_TYPE;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.config.TargetServer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ */
+public class Bootstrap {
+
+  private static final String DB_DRIVER = "db.driver";
+  private static final String DB_URL = "db.url";
+  private static final String DB_USER = "db.user";
+  private static final String DB_PASSWORD = "db.password";
+  private static final String DB_MIN_WRITE = "db.write.min";
+  private static final String DB_MIN_NUM_READ = "db.read.min";
+  private static final Log LOG = LogFactory.getLog(Boolean.class);
+  private String minWrite;
+  private String minRead;
+  private String dbPassword;
+  private String dbUser;
+  private String dbUrl;
+  private String dbDriver;
+  private EntityManager entityManager;
+
+  @Inject
+  public Bootstrap(@Named(DB_DRIVER)
+  String dbDriver, @Named(DB_URL)
+  String dbUrl, @Named(DB_USER)
+  String dbUser, @Named(DB_PASSWORD)
+  String dbPassword, @Named(DB_MIN_NUM_READ)
+  String minRead, @Named(DB_MIN_WRITE)
+  String minWrite) {
+    this.dbDriver = dbDriver;
+    this.dbUrl = dbUrl;
+    this.dbUser = dbUser;
+    this.dbPassword = dbPassword == null || dbPassword.length() == 0 ? " " : dbPassword;
+    this.minRead = minRead;
+    this.minWrite = minWrite;
+
+  }
+
+  public void init(String unitName) {
+
+    Map<String, String> properties = new HashMap<String, String>();
+
+    // Ensure RESOURCE_LOCAL transactions is used.
+    properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name());
+
+    // Configure the internal EclipseLink connection pool
+    properties.put(JDBC_DRIVER, dbDriver);
+    properties.put(JDBC_URL, dbUrl);
+    properties.put(JDBC_USER, dbUser);
+    properties.put(JDBC_PASSWORD, dbPassword);
+    properties.put(JDBC_READ_CONNECTIONS_MIN, minRead);
+    properties.put(JDBC_WRITE_CONNECTIONS_MIN, minWrite);
+
+    // Configure logging. FINE ensures all SQL is shown
+    properties.put(LOGGING_LEVEL, "FINE");
+    properties.put(LOGGING_TIMESTAMP, "true");
+    properties.put(LOGGING_THREAD, "false");
+    properties.put(LOGGING_SESSION, "false");
+
+    // Ensure that no server-platform is configured
+    properties.put(TARGET_SERVER, TargetServer.None);
+
+    properties.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.CREATE_ONLY);
+    properties.put(PersistenceUnitProperties.DROP_JDBC_DDL_FILE, "drop.sql");
+    properties.put(PersistenceUnitProperties.CREATE_JDBC_DDL_FILE, "create.sql");
+    properties.put(PersistenceUnitProperties.DDL_GENERATION_MODE,
+        PersistenceUnitProperties.DDL_BOTH_GENERATION);
+
+    // properties.put(PersistenceUnitProperties.SESSION_CUSTOMIZER,
+    // EnableIntegrityChecker.class.getName());
+
+    LOG.info("Starting connection manager with properties " + properties);
+
+    EntityManagerFactory emFactory = Persistence.createEntityManagerFactory(unitName, properties);
+    entityManager = emFactory.createEntityManager();
+  }
+
+  /**
+   * @param string
+   * @return
+   */
+  public EntityManager getEntityManager(String unitName) {
+    if (entityManager == null) {
+      init(unitName);
+    }
+    return entityManager;
+  }
+}

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/EnableIntegrityChecker.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/EnableIntegrityChecker.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/EnableIntegrityChecker.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/EnableIntegrityChecker.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa.eclipselink;
+
+import org.eclipse.persistence.config.SessionCustomizer;
+import org.eclipse.persistence.sessions.Session;
+
+/**
+ * 
+ */
+public class EnableIntegrityChecker implements SessionCustomizer {
+
+  public void customize(Session session) throws Exception {
+    session.getIntegrityChecker().checkDatabase();
+    session.getIntegrityChecker().setShouldCatchExceptions(false);
+  }
+}
\ No newline at end of file

Added: incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java (added)
+++ incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/openjpa/Bootstrap.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa.openjpa;
+
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_READ_CONNECTIONS_MIN;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_WRITE_CONNECTIONS_MIN;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_LEVEL;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_SESSION;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_THREAD;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_TIMESTAMP;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.TARGET_SERVER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.TRANSACTION_TYPE;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.eclipse.persistence.config.TargetServer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ */
+public class Bootstrap {
+
+  private static final String DB_DRIVER = "db.driver";
+  private static final String DB_URL = "db.url";
+  private static final String DB_USER = "db.user";
+  private static final String DB_PASSWORD = "db.password";
+  private static final String DB_MIN_WRITE = "db.write.min";
+  private static final String DB_MIN_NUM_READ = "db.read.min";
+  private static final Log LOG = LogFactory.getLog(Boolean.class);
+  private String minWrite;
+  private String minRead;
+  private String dbPassword;
+  private String dbUser;
+  private String dbUrl;
+  private String dbDriver;
+  private EntityManager entityManager;
+
+  @Inject
+  public Bootstrap(@Named(DB_DRIVER)
+  String dbDriver, @Named(DB_URL)
+  String dbUrl, @Named(DB_USER)
+  String dbUser, @Named(DB_PASSWORD)
+  String dbPassword, @Named(DB_MIN_NUM_READ)
+  String minRead, @Named(DB_MIN_WRITE)
+  String minWrite) {
+    this.dbDriver = dbDriver;
+    this.dbUrl = dbUrl;
+    this.dbUser = dbUser;
+    this.dbPassword = dbPassword == null || dbPassword.length() == 0 ? " " : dbPassword;
+    this.minRead = minRead;
+    this.minWrite = minWrite;
+
+  }
+
+  public Bootstrap() {
+
+  }
+
+  public void init(String unitName) {
+
+    EntityManagerFactory emFactory = Persistence.createEntityManagerFactory(unitName);
+    entityManager = emFactory.createEntityManager();
+  }
+
+  /**
+   * @param string
+   * @return
+   */
+  public EntityManager getEntityManager(String unitName) {
+    if (entityManager == null) {
+      init(unitName);
+    }
+    return entityManager;
+  }
+}

Added: incubator/shindig/trunk/java/samples/src/main/resources/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/resources/META-INF/MANIFEST.MF?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/resources/META-INF/MANIFEST.MF (added)
+++ incubator/shindig/trunk/java/samples/src/main/resources/META-INF/MANIFEST.MF Mon Sep 15 05:24:17 2008
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

Added: incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml (added)
+++ incubator/shindig/trunk/java/samples/src/main/resources/META-INF/orm.xml Mon Sep 15 05:24:17 2008
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
+  version="1.0"> 
+  <entity class="org.apache.shindig.social.opensocial.jpa.AccountDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.ActivityDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.AddressDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.BodyTypeDb">
+  </entity>
+  <entity
+    class="org.apache.shindig.social.opensocial.jpa.MediaItemDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.NameDb">
+  </entity>
+  <entity
+    class="org.apache.shindig.social.opensocial.jpa.OrganizationDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PersonDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.UrlDb">
+  </entity>
+  <entity
+    class="org.apache.shindig.social.opensocial.jpa.ListFieldDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.MessageDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.ActivityTemplateParamsDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.OrganizationAddressDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.EmailDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.ImDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PersonAccountDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PersonAddressDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PersonOrganizationDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PhoneDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PhotoDb">
+  </entity>
+  <entity class="org.apache.shindig.social.opensocial.jpa.PersonPropertiesDb">
+  </entity>
+</entity-mappings>

Added: incubator/shindig/trunk/java/samples/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/main/resources/META-INF/persistence.xml?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/main/resources/META-INF/persistence.xml (added)
+++ incubator/shindig/trunk/java/samples/src/main/resources/META-INF/persistence.xml Mon Sep 15 05:24:17 2008
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0" 
+  xmlns="http://java.sun.com/xml/ns/persistence" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+  > 
+ <persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
+  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ 
+  <!-- By default your mappings can be defined in orm.xml file, -->
+  <!-- which is discovered automatically.                        -->                                     
+  <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ 
+  <!--  properties are set in Bootstrap no here  -->
+  <properties>
+     <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+     <property name="eclipselink.jdbc.url" value="jdbc:derby:testdb;create=true"/>
+     <property name="eclipselink.jdbc.user" value="sa"/>
+     <property name="eclipselink.jdbc.password" value=" "/>
+     <property name="eclipselink.target-server" value="None"/>
+     
+     <property name="eclipselink.jdbc.write-connections.min" value="1"/>
+     <property name="eclipselink.jdbc.read-connections.min" value="1"/>
+     <property name="eclipselink.logging.level" value="FINE" />
+     <property name="eclipselink.logging.timestamp" value="false" />
+     <property name="eclipselink.logging.session" value="false" />
+     <property name="eclipselink.logging.thread" value="false" />
+     <property name="eclipselink.logging.exceptions" value="false" />
+     <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+     <property name="eclipselink.ddl-generation.output-mode" value="both"/>
+  </properties>
+</persistence-unit>
+
+<persistence-unit name="cayenne">
+  <provider>org.apache.cayenne.jpa.Provider</provider>
+ 
+  <!-- By default your mappings can be defined in orm.xml file, -->
+  <!-- which is discovered automatically.                        -->                                     
+  <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    <properties>
+      <property name="org.apache.cayenne.datasource.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+      <property name="org.apache.cayenne.datasource.jdbc.url" value="jdbc:derby:cayennedb;create=true"/>
+      <property name="org.apache.cayenne.datasource.jdbc.username" value="sa"/>
+      <property name="org.apache.cayenne.datasource.jdbc.password" value=" "/>
+      <property name="org.apache.cayenne.datasource.jdbc.minConnections" value="1"/>
+      <property name="org.apache.cayenne.datasource.jdbc.maxConnections" value="2"/>
+      <property name="org.apache.cayenne.schema.create" value="true"/>
+    </properties>
+  </persistence-unit>
+<persistence-unit name="openjpa">
+  <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ 
+  <!-- By default your mappings can be defined in orm.xml file, -->
+  <!-- which is discovered automatically.                        -->                                     
+  <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    <properties>
+      <property name="openjpa.ConnectionURL" value="jdbc:derby:openjpa;create=true"/>
+      <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+      <property name="openjpa.ConnectionUserName" value="sa"/>
+      <property name="openjpa.ConnectionPassword" value=""/>
+      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
+    </properties>
+  </persistence-unit>
+</persistence>
\ No newline at end of file

Added: incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/PersonPopulate.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/PersonPopulate.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/PersonPopulate.java (added)
+++ incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/PersonPopulate.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+package org.apache.shindig.social.opensocial.jpa.test;
+
+import org.apache.shindig.social.core.model.EnumImpl;
+import org.apache.shindig.social.opensocial.jpa.AddressDb;
+import org.apache.shindig.social.opensocial.jpa.BodyTypeDb;
+import org.apache.shindig.social.opensocial.jpa.EmailDb;
+import org.apache.shindig.social.opensocial.jpa.NameDb;
+import org.apache.shindig.social.opensocial.jpa.OrganizationDb;
+import org.apache.shindig.social.opensocial.jpa.PersonDb;
+import org.apache.shindig.social.opensocial.jpa.PersonOrganizationDb;
+import org.apache.shindig.social.opensocial.jpa.PhoneDb;
+import org.apache.shindig.social.opensocial.jpa.UrlDb;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.BodyType;
+import org.apache.shindig.social.opensocial.model.Enum;
+import org.apache.shindig.social.opensocial.model.ListField;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.Organization;
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Url;
+import org.apache.shindig.social.opensocial.model.Enum.Drinker;
+import org.apache.shindig.social.opensocial.model.Enum.LookingFor;
+import org.apache.shindig.social.opensocial.model.Enum.Smoker;
+import org.apache.shindig.social.opensocial.model.Person.Gender;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.Random;
+
+public class PersonPopulate {
+
+  private EntityManager entityManager;
+
+  /**
+   * 
+   */
+  public PersonPopulate(EntityManager entityManager) {
+    this.entityManager = entityManager;
+    // TODO Auto-generated constructor stub
+  }
+
+  private static final Log log = LogFactory.getLog("shindig-db-test");
+
+  public Person createPerson(int i, long key, Random random) {
+
+    Person person = new PersonDb();
+    person.setAboutMe("About Me " + i);
+    String personId = getPersonId(i, key);
+
+    person.setId(personId);
+    person.setActivities(getList("Activities"));
+    int age = random.nextInt(105);
+    Calendar c = new GregorianCalendar();
+    c.setTimeInMillis(System.currentTimeMillis());
+    c.add(Calendar.YEAR, -age);
+    c.add(Calendar.MONTH, 12 - i % 12);
+    List<Address> a = new ArrayList<Address>();
+    a.add(getNewAddress(i));
+    a.add(getNewAddress(i + 2));
+    person.setAddresses(a);
+    person.setAge(random.nextInt(105));
+    person.setBodyType(getNewBodyType(i));
+    person.setBooks(getList("Books"));
+    person.setCars(getList("Cars"));
+    person.setChildren("Yes");
+    person.setCurrentLocation(getNewAddress(i + 5));
+    person.setBirthday(c.getTime());
+    person.setDrinker(new EnumImpl<Drinker>(Drinker.OCCASIONALLY));
+    List<ListField> emails = new ArrayList<ListField>();
+    emails.add(getNewEmail(i));
+    emails.add(getNewEmail(i + 1));
+    person.setEmails(emails);
+    person.setEthnicity("ethinicity");
+    person.setFashion("fashion");
+    person.setFood(getList("Food"));
+    person.setGender(Gender.female);
+    person.setHappiestWhen("sailing");
+    person.setHeroes(getList("Heroes"));
+    person.setHumor("hahaha");
+    person.setInterests(getList("Interests"));
+    person.setIsOwner(true);
+    person.setIsViewer(true);
+    person.setJobInterests("job interest");
+    List<Organization> organizations = new ArrayList<Organization>();
+    organizations.add(getPersonOrganization(i, "job"));
+    organizations.add(getPersonOrganization(i + 1, "job"));
+    organizations.add(getPersonOrganization(i + 2, "job"));
+    person.setOrganizations(organizations);
+    person.setLanguagesSpoken(getList("LanguagesSpoken"));
+    person.setLivingArrangement("living Arrangement");
+    List<Enum<LookingFor>> lookingFor = new ArrayList<Enum<LookingFor>>();
+    lookingFor.add(new EnumImpl<LookingFor>(LookingFor.RANDOM));
+    lookingFor.add(new EnumImpl<LookingFor>(LookingFor.NETWORKING));
+    person.setLookingFor(lookingFor);
+    person.setMovies(getList("Movies"));
+    person.setMusic(getList("music"));
+    person.setName(getNewName(i));
+    person.setNickname("NickName");
+    person.setPets("Pets");
+    List<ListField> phoneNumbers = new ArrayList<ListField>();
+    phoneNumbers.add(getNewPhone(i));
+    phoneNumbers.add(getNewPhone(i * 3));
+
+    person.setPhoneNumbers(phoneNumbers);
+    person.setPoliticalViews("politicalViews");
+    person.setProfileSong(getNewUrl(i));
+    person.setProfileUrl("Profile URL");
+    person.setProfileVideo(getNewUrl(i * 2));
+    person.setQuotes(getList("Quites"));
+    person.setRelationshipStatus("relationship");
+    person.setReligion("religion");
+    person.setRomance("romance");
+    person.setScaredOf("scaredOf");
+    List<Organization> organizations2 = person.getOrganizations();
+    organizations2.add(getPersonOrganization(i + 5, "school"));
+    organizations2.add(getPersonOrganization(i + 6, "school"));
+    organizations2.add(getPersonOrganization(i + 7, "school"));
+    person.setOrganizations(organizations);
+    person.setSexualOrientation("sexualOrientation");
+    person.setSmoker(new EnumImpl<Smoker>(Smoker.QUITTING));
+    person.setSports(getList("Sports"));
+    person.setStatus("Status");
+    person.setTags(getList("tags"));
+    person.setThumbnailUrl("Thumbnail URL");
+    person.setUtcOffset(1L);
+    person.setTurnOffs(getList("TurnOff"));
+    person.setTurnOns(getList("TurnOns"));
+    person.setTvShows(getList("TvShows"));
+    person.setUpdated(new Date());
+    List<Url> urls = new ArrayList<Url>();
+    urls.add(getNewUrl(i * 4));
+    urls.add(getNewUrl(i * 5));
+    urls.add(getNewUrl(i * 6));
+    person.setUrls(urls);
+
+    // TODO: setActivity
+    // TODO: person.setAccounts(accounts);
+    // TODO: person.setActivities(activities);
+    // TODO: person.setAddresses(addresses);
+
+    log.info("Created user ++++++ " + personId);
+
+    return person;
+  }
+
+  public String getPersonId(int i, long key) {
+    return "Person" + key + ":" + i;
+  }
+
+  private Url getNewUrl(int i) {
+    String targetUrl = "http://sdfsdfsd.sdfdsf/" + String.valueOf(i % 33);
+    List<?> l = find(UrlDb.FINDBY_URL, new String[] { UrlDb.PARAM_URL }, new Object[] { targetUrl });
+    if (l.size() == 0) {
+      Url url = new UrlDb();
+      url.setValue(targetUrl);
+      url.setLinkText("LinkText");
+      url.setType("URL");
+      return url;
+    } else {
+      return (Url) l.get(0);
+    }
+  }
+
+  private PhoneDb getNewPhone(int i) {
+    String targetPhone = String.valueOf(i % 33);
+    PhoneDb phone = findOne(PhoneDb.FINDBY_PHONE_NUMBER,
+        new String[] { PhoneDb.PARAM_PHONE_NUMBER }, new Object[] { targetPhone });
+    if (phone == null) {
+      phone = new PhoneDb();
+      phone.setValue(targetPhone);
+      phone.setType("Mobile");
+    }
+    return phone;
+  }
+
+  private Name getNewName(int i) {
+    String targetName = String.valueOf("FamilyName" + (i % 25));
+    Name name = findOne(NameDb.FINDBY_FAMILY_NAME, new String[] { NameDb.PARAM_FAMILY_NAME },
+        new Object[] { targetName });
+    if (name == null) {
+      name = new NameDb();
+      name.setFamilyName(targetName);
+      name.setGivenName("GivenName");
+      name.setHonorificPrefix("Hprefix");
+      name.setHonorificSuffix("HSufix");
+      name.setFormatted("formatted");
+      name.setAdditionalName("Additional Names");
+    }
+    return name;
+  }
+
+  private List<String> getList(String base) {
+    List<String> list = new ArrayList<String>();
+    for (int i = 0; i < 10; i++) {
+      list.add(base + i);
+    }
+    return list;
+  }
+
+  private Organization getDbOrganization(int i, String type) {
+
+    String targetOrg = "Organization_" + (i % 10);
+    Organization organization = findOne(OrganizationDb.FINDBY_NAME,
+        new String[] { OrganizationDb.PARAM_NAME }, new Object[] { targetOrg });
+
+    if (organization == null) {
+      organization = new OrganizationDb();
+      organization.setAddress(getNewAddress(i * 3));
+      organization.setName(targetOrg);
+      organization.setSubField("SubField");
+      organization.setTitle("Title");
+      organization.setWebpage("http://sdfsd.sdfsdf.sdfsdf");
+    }
+    return organization;
+  }
+
+  private Organization getPersonOrganization(int i, String type) {
+    String targetOrg = "Organization_" + (i % 10);
+    PersonOrganizationDb organization = findOne(PersonOrganizationDb.PERSON_ORG_FINDBY_NAME,
+        new String[] { PersonOrganizationDb.PARAM_NAME }, new Object[] { targetOrg });
+    if (organization == null) {
+      organization = new PersonOrganizationDb();
+      organization.setDescription("Description");
+      organization.setEndDate(new Date(System.currentTimeMillis()
+          + (24L * 3600L * 1000L * 365L * 2L)));
+      organization.setAddress(getNewAddress(i * 3));
+      organization.setName(targetOrg);
+      organization.setSalary(String.valueOf(i * 1000));
+      organization.setStartDate(new Date(System.currentTimeMillis()
+          - (24L * 3600L * 1000L * 365L * 2L)));
+      organization.setField("Field");
+      organization.setSubField("SubField");
+      organization.setTitle("Title");
+      organization.setType(type);
+      organization.setWebpage("http://sdfsd.sdfsdf.sdfsdf");
+    }
+    return organization;
+
+  }
+
+  @SuppressWarnings("unchecked")
+  private <T> T find(String query, String[] names, Object[] params) {
+    Query q = entityManager.createNamedQuery(query);
+    for (int i = 0; i < names.length; i++) {
+      q.setParameter(names[i], params[i]);
+    }
+    return (T) q.getResultList();
+  }
+
+  private <T> T findOne(String query, String[] names, Object[] params) {
+    List<T> l = find(query, names, params);
+    if (l.size() > 0) {
+      return (T) l.get(0);
+    }
+    return null;
+  }
+
+  private ListField getNewEmail(int i) {
+    String targetAddress = "xyz" + i + "@testdataset.com";
+    ListField email = findOne(EmailDb.FINDBY_EMAIL, new String[] { EmailDb.PARAM_EMAIL },
+        new Object[] { targetAddress });
+    if (email == null) {
+      email = new EmailDb();
+      email.setValue(targetAddress);
+      email.setType("emailType");
+    }
+    return email;
+  }
+
+  private BodyType getNewBodyType(int i) {
+    BodyType bodyType = findOne(BodyTypeDb.FINDBY_HEIGHT, new String[] { BodyTypeDb.PARAM_HEIGHT },
+        new Object[] { String.valueOf(i % 10) });
+    if (bodyType == null) {
+      bodyType = new BodyTypeDb();
+      bodyType.setBuild("Build " + i);
+      bodyType.setEyeColor("Build " + i);
+      bodyType.setHairColor("Build " + i);
+      bodyType.setHeight(String.valueOf(i % 10));
+      bodyType.setWeight(String.valueOf(i % 15));
+    }
+    return bodyType;
+  }
+
+  private Address getNewAddress(int i) {
+    Address address = findOne(AddressDb.FINDBY_POSTCODE, new String[] { AddressDb.PARAM_POSTCODE },
+        new Object[] { String.valueOf(i % 10) });
+    if (address == null) {
+      address = new AddressDb();
+      address.setCountry("UK");
+      address.setLatitude(new Float(0.5));
+      address.setLongitude(new Float(0.0));
+      address.setPostalCode(String.valueOf(i % 10));
+      address.setRegion("CAMBS");
+      address.setStreetAddress("High Street");
+      address.setType("sometype:");
+      address.setFormatted("formatted address");
+      address.setLocality("locality");
+      address.setPrimary(false);
+      address.setType("home");
+    }
+    return address;
+  }
+
+  public void destroyPerson(int i, long key) {
+    List<Person> people = find(PersonDb.FINDBY_LIKE_PERSONID,
+        new String[] { PersonDb.PARAM_PERSONID }, new Object[] { getPersonId(i, key) });
+    for (Person o : people) {
+      entityManager.remove(o);
+    }
+  }
+
+  protected Person getPerson(String id) {
+    return find(PersonDb.FINDBY_PERSONID, new String[] { PersonDb.PARAM_PERSONID },
+        new Object[] { id });
+  }
+
+}

Added: incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaOpenJPATestOff.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaOpenJPATestOff.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaOpenJPATestOff.java (added)
+++ incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaOpenJPATestOff.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa.test;
+
+
+import org.apache.shindig.social.opensocial.jpa.EmailDb;
+import org.apache.shindig.social.opensocial.jpa.openjpa.Bootstrap;
+import org.apache.shindig.social.opensocial.model.Person;
+
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+import java.util.Random;
+
+/**
+ *
+ */
+public class SchemaOpenJPATestOff {
+  
+  private static EntityManager entityManager;
+
+  //@BeforeClass
+  public static void config() {
+    Bootstrap b = new Bootstrap();
+    //Bootstrap b = new Bootstrap("com.mysql.jdbc.Driver","jdbc:mysql://localhost/sakaikernel?useUnicode=true&amp;characterEncoding=UTF-8","sakaikernel","sakaikernel","1","1");
+    entityManager = b.getEntityManager("openjpa");
+  }
+  
+  //@AfterClass
+  public static void stop() {
+  }
+
+  //@Test
+  public void checkSimpleInsert() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    EmailDb email = new EmailDb();
+    email.setType("email");
+    email.setValue("ieb@tfd.co.uk");
+    entityManager.persist(email);
+    transaction.commit();
+  }
+  
+  //@Test
+  public void checkPersonCreate() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    PersonPopulate pp = new PersonPopulate(entityManager);
+    int i = 1;
+    long key= System.currentTimeMillis();
+    Random r = new Random();
+    Person p = pp.createPerson(i, key, r);
+    entityManager.persist(p);
+    transaction.commit();
+  }
+
+  //@Test
+  public void fillDatbase() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    PersonPopulate pp = new PersonPopulate(entityManager);
+    long key= System.currentTimeMillis();
+    Random r = new Random();
+    for ( int i = 0; i < 20; i++ ) {
+      Person p = pp.createPerson(i, key, r);
+      entityManager.persist(p);
+      if ( i%10 == 0 ) {
+        transaction.commit();
+        transaction = entityManager.getTransaction();
+        transaction.begin();
+      }
+    }
+    transaction.commit();
+  }
+
+}

Added: incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaTest.java?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaTest.java (added)
+++ incubator/shindig/trunk/java/samples/src/test/java/org/apache/shindig/social/opensocial/jpa/test/SchemaTest.java Mon Sep 15 05:24:17 2008
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.shindig.social.opensocial.jpa.test;
+
+import org.apache.shindig.social.opensocial.jpa.EmailDb;
+import org.apache.shindig.social.opensocial.jpa.eclipselink.Bootstrap;
+import org.apache.shindig.social.opensocial.model.Person;
+
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+
+import java.util.Random;
+
+/**
+ *
+ */
+public class SchemaTest {
+  
+  private static EntityManager entityManager;
+
+  @BeforeClass
+  public static void config() {
+    Bootstrap b = new Bootstrap("org.apache.derby.jdbc.EmbeddedDriver","jdbc:derby:testdb;create=true","sa","","1","1");
+    //Bootstrap b = new Bootstrap("com.mysql.jdbc.Driver","jdbc:mysql://localhost/sakaikernel?useUnicode=true&amp;characterEncoding=UTF-8","sakaikernel","sakaikernel","1","1");
+    entityManager = b.getEntityManager("default");
+  }
+  
+  @AfterClass
+  public static void stop() {
+  }
+
+  @Test
+  public void checkSimpleInsert() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    EmailDb email = new EmailDb();
+    email.setType("email");
+    email.setValue("ieb@tfd.co.uk");
+    entityManager.persist(email);
+    transaction.commit();
+  }
+  
+  @Test
+  public void checkPersonCreate() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    PersonPopulate pp = new PersonPopulate(entityManager);
+    int i = 1;
+    long key= System.currentTimeMillis();
+    Random r = new Random();
+    Person p = pp.createPerson(i, key, r);
+    entityManager.persist(p);
+    transaction.commit();
+  }
+
+  @Test
+  public void fillDatbase() throws Exception {
+    EntityTransaction transaction = entityManager.getTransaction();
+    transaction.begin();
+    PersonPopulate pp = new PersonPopulate(entityManager);
+    long key= System.currentTimeMillis();
+    Random r = new Random();
+    for ( int i = 0; i < 20; i++ ) {
+      Person p = pp.createPerson(i, key, r);
+      entityManager.persist(p);
+      if ( i%10 == 0 ) {
+        transaction.commit();
+        transaction = entityManager.getTransaction();
+        transaction.begin();
+      }
+    }
+    transaction.commit();
+  }
+
+}

Added: incubator/shindig/trunk/java/samples/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/samples/src/test/resources/log4j.properties?rev=695451&view=auto
==============================================================================
--- incubator/shindig/trunk/java/samples/src/test/resources/log4j.properties (added)
+++ incubator/shindig/trunk/java/samples/src/test/resources/log4j.properties Mon Sep 15 05:24:17 2008
@@ -0,0 +1,8 @@
+log4j.rootCategory=info
+log4j.rootLogger=info, stdout
+
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern= %p %m  [%d] (%F:%L) %n
+