Additional tests and support for moving EditionSet.java(s) and verifying broken references
diff --git a/Temporal Entity Example/src/temporal/BaseTemporalEntity.java b/Temporal Entity Example/src/temporal/BaseTemporalEntity.java
index 3d59652..59f3d9f 100644
--- a/Temporal Entity Example/src/temporal/BaseTemporalEntity.java
+++ b/Temporal Entity Example/src/temporal/BaseTemporalEntity.java
@@ -44,8 +44,8 @@
 
     @Embedded
     private Effectivity effectivity = new Effectivity();
-    
-    @Column(name="CID", insertable=false, updatable=false)
+
+    @Column(name = "CID", insertable = false, updatable = false)
     private int continuityId;
 
     public T getContinuity() {
@@ -54,10 +54,15 @@
 
     public void setContinuity(T continuity) {
         this.continuity = continuity;
-        this.continuityId = continuity.getId();
+        if (continuity != null) {
+            this.continuityId = continuity.getId();
+        }
     }
 
     public int getContinuityId() {
+        if (this.continuityId <= 0 && getContinuity() != null) {
+            this.continuityId = getContinuity().getId();
+        }
         return continuityId;
     }
 
@@ -72,9 +77,9 @@
     public void setPreviousEdition(T previousEdition) {
         this.previousEdition = previousEdition;
     }
-    
+
     public boolean isContinuity() {
-        return getContinuity() != null &&  getId() == getContinuity().getId();
+        return getContinuity() != null && getId() == getContinuity().getId();
     }
-    
+
 }
\ No newline at end of file
diff --git a/Temporal Entity Example/src/temporal/EditionSet.java b/Temporal Entity Example/src/temporal/EditionSet.java
index 536e480..1afa9e5 100644
--- a/Temporal Entity Example/src/temporal/EditionSet.java
+++ b/Temporal Entity Example/src/temporal/EditionSet.java
@@ -60,6 +60,10 @@
         return effective;
     }
 
+    protected void setEffective(long effective) {
+        this.effective = effective;
+    }
+
     public String getDescription() {
         return description;
     }
@@ -87,9 +91,30 @@
         return false;
     }
 
+
+    protected EditionSetEntry get(Temporal temporal) {
+        for (EditionSetEntry ese: getEntries()) {
+            if (ese.getTemporal().equals(temporal)) {
+                return ese;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Remove the provided entity and its associated {@link EditionSetEntry}.
+     * TODO: Throw exception if no ESE found
+     */
+    protected EditionSetEntry remove(Temporal temporal) {
+        EditionSetEntry ese = get(temporal);
+        if (ese != null) {
+            getEntries().remove(ese);
+        }
+        return ese;
+    }
+
     @Override
     public String toString() {
         return "EditionSet(" + Effectivity.timeString(getEffective()) + ")";
     }
-
 }
diff --git a/Temporal Entity Example/src/temporal/EditionSetEntry.java b/Temporal Entity Example/src/temporal/EditionSetEntry.java
index 3f7314f..ba9a9c6 100644
--- a/Temporal Entity Example/src/temporal/EditionSetEntry.java
+++ b/Temporal Entity Example/src/temporal/EditionSetEntry.java
@@ -95,6 +95,10 @@
         return editionSet;
     }
 
+    protected void setEditionSet(EditionSet editionSet) {
+        this.editionSet = editionSet;
+    }
+
     public Set<String> getAttributes() {
         return attributes;
     }
diff --git a/Temporal Entity Example/src/temporal/EditionSetHelper.java b/Temporal Entity Example/src/temporal/EditionSetHelper.java
index ad5df16..4166eac 100644
--- a/Temporal Entity Example/src/temporal/EditionSetHelper.java
+++ b/Temporal Entity Example/src/temporal/EditionSetHelper.java
@@ -46,10 +46,8 @@
     public static void apply(EntityManager em, EditionSet editionSet) {
         for (EditionSetEntry ese : editionSet.getEntries()) {
             copyValues(em, ese);
-
-            em.remove(ese.getTemporal());
-
         }
+        em.remove(editionSet);
     }
 
     public static void copyValues(EntityManager em, EditionSetEntry entry) {
@@ -79,19 +77,35 @@
     }
 
     /**
-     * Remove and {@link EditionSet} along with all of its entries. Any future
-     * edition value propagation must be undone in this method.
+     * Move the provided {@link EditionSet} to the new effective time
      * 
-     * @see TemporalEntityManager#remove(Object)
-     * @param temporalEntityManager
-     * @param entity
+     * @throws IllegalArgumentException
+     *             for invalid effective time or mismatched
+     *             {@link TemporalEntityManager} and {@link EditionSet}
      */
-    protected static void remove(TemporalEntityManager em, EditionSet editionSet) {
-        System.out.println("EditionSetHelper.remove: " + editionSet);
-        
-        for (EditionSetEntry ese: editionSet.getEntries()) {
-            em.remove(ese.getTemporal());
+    public static EditionSet move(TemporalEntityManager em, EditionSet es, long effective) {
+        if (effective <= Effectivity.BOT) {
+            throw new IllegalArgumentException("Invalid effective time for move: " + effective);
         }
+        if (es == null || !es.equals(em.getEditionSet())) {
+            throw new IllegalArgumentException("Invalid TemporalEntitymanager or EditionSet: " + em + "::" + es);
+        }
+        
+        EditionSet newES = new EditionSet(effective);
+        em.persist(newES);
+        
+        for (EditionSetEntry entry : es.getEntries()) {
+            // TODO: Look for conflicts
+            entry.getTemporal().getEffectivity().setStart(effective);
+            newES.getEntries().add(entry);
+            entry.setEditionSet(newES);
+        }
+        es.getEntries().clear();
+        em.remove(es);
+        
+        em.setEditionSet(newES);
+        
+        return newES;
     }
 
 }
diff --git a/Temporal Entity Example/src/temporal/TemporalEntityManager.java b/Temporal Entity Example/src/temporal/TemporalEntityManager.java
index dc22d48..d3cfbe6 100644
--- a/Temporal Entity Example/src/temporal/TemporalEntityManager.java
+++ b/Temporal Entity Example/src/temporal/TemporalEntityManager.java
@@ -163,6 +163,11 @@
         return this.editionSet;
     }
 
+    protected void setEditionSet(EditionSet editionSet) {
+        this.editionSet = editionSet;
+        this.effective = editionSet.getEffective();
+    }
+
     public boolean hasEditionSet() {
         return this.editionSet != null;
     }
@@ -500,10 +505,16 @@
 
     @Override
     public void remove(Object entity) {
-        super.remove(entity);
-        if (entity instanceof EditionSet) {
-            EditionSetHelper.remove(this, (EditionSet) entity);
+        if (entity instanceof Temporal && hasEditionSet()) {
+            EditionSetEntry ese = getEditionSet().remove((Temporal) entity);
+            if (ese != null) {
+                super.remove(ese);
+            }
         }
+        if (entity instanceof TemporalEntity<?>) {
+            ((TemporalEntity<?>) entity).setContinuity(null);
+        }
+        super.remove(entity);
     }
 
     public String toString() {
diff --git a/Temporal Entity Example/src/temporal/persistence/PropagateEditionChangesListener.java b/Temporal Entity Example/src/temporal/persistence/PropagateEditionChangesListener.java
index 047bc46..7d8f4cf 100644
--- a/Temporal Entity Example/src/temporal/persistence/PropagateEditionChangesListener.java
+++ b/Temporal Entity Example/src/temporal/persistence/PropagateEditionChangesListener.java
@@ -80,7 +80,7 @@
         if (desc != null) {
             ReadAllQuery raq = new ReadAllQuery(desc.getJavaClass());
             ExpressionBuilder eb = raq.getExpressionBuilder();
-            Expression cidExp = eb.get("cid").equal(entry.getTemporalEntity().getContinuity().getId());
+            Expression cidExp = eb.get("cid").equal(entry.getTemporalEntity().getContinuityId());
             Expression startExp = eb.get("effectivity").get("start");
             Expression futureExp = startExp.greaterThan(entry.getEditionSet().getEffective());
             raq.setSelectionCriteria(cidExp.and(futureExp));
@@ -97,6 +97,13 @@
      */
     private void propogateChanges(RepeatableWriteUnitOfWork uow, List<TemporalEntity<?>> futures, EditionSetEntry entry, ChangeRecord record) {
         if (!futures.isEmpty() && !(record instanceof DirectToFieldChangeRecord)) {
+            // Ignore if future edition view is myself
+            if (futures.size() == 1) {
+                TemporalEntity<?> future = futures.get(0);
+                if (future.getId() == entry.getTemporalEntity().getId()) {
+                    return;
+                }
+            }
             throw new UnsupportedOperationException("Only direct mapping changes can be propagated");
         }
 
diff --git a/Temporal Tests/src/tests/BaseTestCase.java b/Temporal Tests/src/tests/BaseTestCase.java
index 6fccb5c..5b792ce 100644
--- a/Temporal Tests/src/tests/BaseTestCase.java
+++ b/Temporal Tests/src/tests/BaseTestCase.java
@@ -31,6 +31,7 @@
 import temporal.persistence.TemporalSchemaManager;
 
 /**
+ * TODO
  * 
  * @author dclarke
  * @Since EclipseLink 2.3.1
diff --git a/Temporal Tests/src/tests/editionsets/AllTests.java b/Temporal Tests/src/tests/editionsets/AllTests.java
index ed46d1d..34828c4 100644
--- a/Temporal Tests/src/tests/editionsets/AllTests.java
+++ b/Temporal Tests/src/tests/editionsets/AllTests.java
@@ -20,6 +20,8 @@
                 ApplySimpleEditionSetTests.class, 
                 MoveSingleEditionSetTests.class,
                 DeleteEditionSetTests.class,
-                PropagateChangesTests.class})
+                PropagateChangesTests.class,
+                PropagateDeleteChangesTests.class,
+                BrokenTemporalReferenceTests.class})
 public class AllTests {
 }
diff --git a/Temporal Tests/src/tests/editionsets/BrokenTemporalReferenceTests.java b/Temporal Tests/src/tests/editionsets/BrokenTemporalReferenceTests.java
new file mode 100644
index 0000000..f29f92b
--- /dev/null
+++ b/Temporal Tests/src/tests/editionsets/BrokenTemporalReferenceTests.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ * 
+ * Contributors: dclarke - Bug 361016: Future Versions Examples
+ ******************************************************************************/
+package tests.editionsets;
+
+import static example.PersonModelExample.*;
+
+import javax.persistence.RollbackException;
+
+import junit.framework.Assert;
+import model.Address;
+import model.Person;
+
+import org.junit.Test;
+
+import temporal.TemporalEntityManager;
+import tests.BaseTestCase;
+
+/**
+ * 
+ * 
+ * @author dclarke
+ * @since EclipseLink 2.3.1
+ */
+public class BrokenTemporalReferenceTests extends BaseTestCase {
+
+    /**
+     * SETUP 1. Create new AddressEntity to exist at T2 2. Create new
+     * PersonEdition at T4 3. Reference Address@T2 from Person@T4 TEST Delete
+     * EditionSet@T2 including new
+     */
+    @Test
+    public void breakFKDeletingEarliedEntity() {
+        TemporalEntityManager em = getEntityManager();
+        em.setEffectiveTime(T2);
+        
+        em.getTransaction().begin();
+        Address aT2 = em.newEntity(Address.class);
+        em.getTransaction().commit();
+        
+        Assert.assertTrue(aT2.getContinuityId() > 0);
+        em.close();
+        
+        em = getEntityManager();
+        em.setEffectiveTime(T4);
+        
+        em.getTransaction().begin();
+        Person pT4 = em.newEntity(Person.class);
+        Address aT4 = em.find(Address.class, aT2.getContinuityId());
+        
+        Assert.assertNotNull(aT4);
+        Assert.assertEquals(T2, aT4.getEffectivity().getStart());
+        
+        pT4.setAddress(aT4);
+        em.getTransaction().commit();
+        em.close();
+        
+        em = getEntityManager();
+        em.setEffectiveTime(T2);
+        aT2 = em.find(Address.class, aT2.getContinuityId());
+        
+        em.getTransaction().begin();
+        em.remove(aT2);
+        
+        try {
+        em.getTransaction().commit();
+        } catch (RollbackException e) {
+            return;
+        }
+        Assert.fail("RollbackException execpted for violating FK");
+    }
+}
diff --git a/Temporal Tests/src/tests/editionsets/DeleteEditionSetTests.java b/Temporal Tests/src/tests/editionsets/DeleteEditionSetTests.java
index 094d987..c559415 100644
--- a/Temporal Tests/src/tests/editionsets/DeleteEditionSetTests.java
+++ b/Temporal Tests/src/tests/editionsets/DeleteEditionSetTests.java
@@ -17,6 +17,7 @@
 import static example.PersonModelExample.T4;
 import static example.PersonModelExample.T5;
 import static temporal.Effectivity.BOT;
+import static temporal.Effectivity.EOT;
 
 import java.util.List;
 
@@ -79,8 +80,8 @@
         Assert.assertEquals(T2, ph.getEffectivity().getStart());
         Assert.assertEquals(PersonModelExample.GOLF, ph.getName());
         Assert.assertEquals(PersonModelExample.GOLF, ph.getHobby().getName());
-        
-        //Assert.assertSame(p, ph.getPerson());
+
+        // Assert.assertSame(p, ph.getPerson());
 
         Assert.assertEquals(1, p.getPersonHobbies().size());
 
@@ -114,14 +115,14 @@
         Assert.assertEquals(T4, ph.getEffectivity().getStart());
         Assert.assertEquals(PersonModelExample.RUN, ph.getName());
         Assert.assertEquals(PersonModelExample.RUN, ph.getHobby().getName());
-        //Assert.assertSame(p, ph.getPerson());
+        // Assert.assertSame(p, ph.getPerson());
 
         Assert.assertTrue(es.getEntries().get(4).getTemporal() instanceof PersonHobby);
         ph = (PersonHobby) es.getEntries().get(4).getTemporal();
         Assert.assertEquals(T4, ph.getEffectivity().getStart());
         Assert.assertEquals(PersonModelExample.SKI, ph.getName());
         Assert.assertEquals(PersonModelExample.SKI, ph.getHobby().getName());
-        //Assert.assertSame(p, ph.getPerson());
+        // Assert.assertSame(p, ph.getPerson());
 
         Assert.assertEquals(2, p.getPersonHobbies().size());
 
@@ -143,8 +144,7 @@
         EditionSet t2 = editionSets.get(1);
         Assert.assertNotNull(t2);
         Assert.assertEquals(T4, t2.getEffective());
-        
-        
+
     }
 
     /**
@@ -174,48 +174,81 @@
 
         Assert.assertTrue(entry.getTemporal() instanceof PersonHobby);
     }
-    
+
     /**
-     * TODO 
+     * TODO
      */
-   // @Test
+    @Test
     public void deleteT4() {
         TemporalEntityManager em = getEntityManager();
         em.setEffectiveTime(T4);
-        
+
         EditionSet esT4 = em.getEditionSet();
-        
+
         Assert.assertNotNull(esT4);
-        
+
         em.getTransaction().begin();
         em.remove(esT4);
-        
-        em.flush();
-        
+        em.getTransaction().commit();
+
         esT4 = em.find(EditionSet.class, T4);
         Assert.assertNull(esT4);
     }
 
     /**
-     * TODO 
+     * TODO
      */
-  //  @Test
+    @Test
     public void deleteT2() {
         TemporalEntityManager em = getEntityManager();
         em.setEffectiveTime(T2);
-        
+
         EditionSet esT2 = em.getEditionSet();
-        
+
         Assert.assertNotNull(esT2);
-        
+
         em.getTransaction().begin();
         em.remove(esT2);
-        
-        em.flush();
+        em.getTransaction().commit();
 
-        esT2= em.find(EditionSet.class, T2);
+        esT2 = em.find(EditionSet.class, T2);
         Assert.assertNull(esT2);
-}
+    }
+
+    /**
+     * Create future edition of Address@T2 and delete it.
+     */
+    @Test
+    public void deleteFutureEntity() {
+        TemporalEntityManager em = getEntityManager();
+        em.setEffectiveTime(T2);
+
+        em.getTransaction().begin();
+
+        Address addr = em.newEntity(Address.class);
+
+        Assert.assertNotNull(addr);
+        Assert.assertEquals(T2, addr.getEffectivity().getStart());
+        Assert.assertEquals(EOT, addr.getEffectivity().getEnd());
+        Assert.assertSame(addr, addr.getContinuity());
+        Assert.assertTrue(addr.getContinuityId() > 0);
+
+        em.getTransaction().commit();
+        em.close();
+
+        em = getEntityManager();
+        em.setEffectiveTime(T2);
+
+        addr = em.find(Address.class, addr.getContinuityId());
+
+        Assert.assertNotNull(addr);
+        Assert.assertEquals(T2, addr.getEffectivity().getStart());
+        Assert.assertEquals(EOT, addr.getEffectivity().getEnd());
+
+        em.getTransaction().begin();
+        em.remove(addr);
+        em.getTransaction().commit();
+    }
 
     /**
      * Populate initial sample entity
diff --git a/Temporal Tests/src/tests/editionsets/MoveSingleEditionSetTests.java b/Temporal Tests/src/tests/editionsets/MoveSingleEditionSetTests.java
index 921f404..9b0f446 100644
--- a/Temporal Tests/src/tests/editionsets/MoveSingleEditionSetTests.java
+++ b/Temporal Tests/src/tests/editionsets/MoveSingleEditionSetTests.java
@@ -11,8 +11,11 @@
 package tests.editionsets;
 
 import static example.PersonModelExample.GOLF;
+import static example.PersonModelExample.T1;
 import static example.PersonModelExample.T2;
+import static example.PersonModelExample.*;
 import junit.framework.Assert;
+import static temporal.Effectivity.*;
 import model.Address;
 import model.Person;
 import model.Phone;
@@ -21,6 +24,7 @@
 
 import temporal.EditionSet;
 import temporal.EditionSetEntry;
+import temporal.EditionSetHelper;
 import temporal.TemporalEntityManager;
 import tests.BaseTestCase;
 import example.PersonModelExample;
@@ -43,8 +47,45 @@
     public void moveEditionSetFromT2toT3() {
         TemporalEntityManager em = getEntityManager();
 
+        em.setEffectiveTime(T2);
+        EditionSet es = em.getEditionSet();
+
+        Assert.assertNotNull(es);
+        Assert.assertEquals(T2, es.getEffective());
+        Assert.assertEquals(3, es.getEntries().size());
+
+        for (EditionSetEntry entry : es.getEntries()) {
+            Assert.assertEquals(T2, entry.getTemporal().getEffectivity().getStart());
+        }
+
+        // Make the move
         em.getTransaction().begin();
 
+        EditionSet newES = EditionSetHelper.move(em, es, T3);
+
+        Assert.assertEquals(T2, es.getEffective());
+        Assert.assertEquals(0, es.getEntries().size());
+        Assert.assertFalse(es.hasChanges());
+        
+        Assert.assertNotNull(newES);
+        Assert.assertSame(newES, em.getEditionSet());
+        Assert.assertEquals(T3, (long) em.getEffectiveTime());
+        Assert.assertEquals(T3, newES.getEffective());
+        Assert.assertEquals(3, newES.getEntries().size());
+        Assert.assertTrue(newES.hasChanges());
+
+        for (EditionSetEntry entry : newES.getEntries()) {
+            Assert.assertEquals(T3, entry.getTemporal().getEffectivity().getStart());
+        }
+
+        em.flush();
+
+    }
+
+    @Test
+    public void moveEditionSetFromT2toT1() {
+        TemporalEntityManager em = getEntityManager();
+
         em.setEffectiveTime(T2);
         EditionSet es = em.getEditionSet();
 
@@ -53,11 +94,57 @@
         Assert.assertEquals(3, es.getEntries().size());
 
         for (EditionSetEntry entry : es.getEntries()) {
-            System.out.println("> " + entry.getTemporal());
-            for (String attrName : entry.getAttributes()) {
-                System.out.println("\t>> " + attrName);
-            }
+            Assert.assertEquals(T2, entry.getTemporal().getEffectivity().getStart());
         }
+
+        // Make the move
+        em.getTransaction().begin();
+
+        EditionSet newES = EditionSetHelper.move(em, es, T1);
+
+        Assert.assertEquals(T2, es.getEffective());
+        Assert.assertEquals(0, es.getEntries().size());
+        Assert.assertFalse(es.hasChanges());
+
+        Assert.assertNotNull(newES);
+        Assert.assertSame(newES, em.getEditionSet());
+        Assert.assertEquals(T1, (long) em.getEffectiveTime());
+        Assert.assertEquals(T1, newES.getEffective());
+        Assert.assertEquals(3, newES.getEntries().size());
+        Assert.assertTrue(newES.hasChanges());
+
+        for (EditionSetEntry entry : newES.getEntries()) {
+            Assert.assertEquals(T1, entry.getTemporal().getEffectivity().getStart());
+        }
+
+        em.flush();
+
+    }
+
+    @Test
+    public void moveEditionSetFromT2toBOT() {
+        TemporalEntityManager em = getEntityManager();
+
+        em.setEffectiveTime(T2);
+        EditionSet es = em.getEditionSet();
+
+        Assert.assertNotNull(es);
+        Assert.assertEquals(T2, es.getEffective());
+        Assert.assertEquals(3, es.getEntries().size());
+
+        for (EditionSetEntry entry : es.getEntries()) {
+            Assert.assertEquals(T2, entry.getTemporal().getEffectivity().getStart());
+        }
+
+        // Make the move
+        em.getTransaction().begin();
+
+        try {
+            EditionSetHelper.move(em, es, BOT);
+        } catch (IllegalArgumentException iae) {
+            return;
+        }
+        Assert.fail("Expected IllegalArgumentException not thrown");
     }
 
     /**
diff --git a/Temporal Tests/src/tests/editionsets/PropagateDeleteChangesTests.java b/Temporal Tests/src/tests/editionsets/PropagateDeleteChangesTests.java
new file mode 100644
index 0000000..b85cd66
--- /dev/null
+++ b/Temporal Tests/src/tests/editionsets/PropagateDeleteChangesTests.java
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2011-2012 Oracle. All rights reserved. This program and the
+ * accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies
+ * this distribution. The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution
+ * License is available at http://www.eclipse.org/org/documents/edl-v10.php.
+ * 
+ * Contributors: dclarke - Bug 361016: Future Versions Examples
+ ******************************************************************************/
+package tests.editionsets;
+
+import static example.PersonModelExample.GOLF;
+import static example.PersonModelExample.RUN;
+import static example.PersonModelExample.SWIM;
+import static example.PersonModelExample.T2;
+import static example.PersonModelExample.T4;
+import junit.framework.Assert;
+import model.Address;
+import model.Person;
+import model.Phone;
+
+import org.junit.Test;
+
+import temporal.EditionSet;
+import temporal.TemporalEntityManager;
+import temporal.TemporalHelper;
+import tests.BaseTestCase;
+import example.PersonModelExample;
+
+/**
+ * Tests change propagation through future editions.
+ * 
+ * @author dclarke
+ * @since EclipseLink 2.3.1
+ */
+public class PropagateDeleteChangesTests extends BaseTestCase {
+
+    private static PersonModelExample example = new PersonModelExample();
+
+    private Person getSample() {
+        return example.fullPerson;
+    }
+
+    @Test
+    public void makeBasicChangesAtT2Changes() {
+        TemporalEntityManager em = getEntityManager();
+
+        em.getTransaction().begin();
+
+        em.setEffectiveTime(T2);
+        EditionSet esT2 = em.getEditionSet();
+        Assert.assertNotNull(esT2);
+
+        Person personT2 = em.find(Person.class, getSample().getId());
+
+        Assert.assertNotNull(personT2);
+        Assert.assertTrue(TemporalHelper.isEdition(em, personT2));
+        Assert.assertEquals(T2, personT2.getEffectivity().getStart());
+
+        personT2.setName("Jimster");
+        personT2.setEmail("a@b.c");
+        personT2.getAddress().setState("ONT");
+        personT2.getAddress().setStreet(null);
+
+        em.getTransaction().commit();        
+        em.close();
+        
+        em = TemporalEntityManager.getInstance(getEntityManager());
+        em.setEffectiveTime(T2);
+        
+        esT2 = em.getEditionSet();
+        
+        Assert.assertNotNull(esT2);
+        Assert.assertTrue(esT2.hasChanges());
+        
+        em.getTransaction().begin();
+        em.remove(esT2);
+        
+        em.flush();
+    }
+
+    @Test
+    public void makeBasicCollectionChangesAtT2Changes() {
+        TemporalEntityManager em = getEntityManager();
+
+        em.getTransaction().begin();
+
+        em.setEffectiveTime(T2);
+        EditionSet esT2 = em.getEditionSet();
+        Assert.assertNotNull(esT2);
+
+        Person personT2 = em.find(Person.class, getSample().getId());
+
+        Assert.assertNotNull(personT2);
+        Assert.assertTrue(TemporalHelper.isEdition(em, personT2));
+        Assert.assertEquals(T2, personT2.getEffectivity().getStart());
+
+        em.persist(personT2.addHobby(example.hobbies.get(SWIM), T2));
+
+        try {
+            em.flush();
+        } catch (UnsupportedOperationException e) {
+            return;
+        }
+        Assert.fail("UnsupportedOperationException expected");
+
+    }
+
+    /**
+     * Populate initial sample entity
+     */
+    @Override
+    public void populate(TemporalEntityManager em) {
+        System.out.println("\nEditionSetTests.populate:START");
+        example.populateHobbies(em);
+        em.persist(getSample());
+        populateT2Editions(em);
+        populateT4Editions(em);
+        System.out.println("\nEditionSetTests.populate::DONE");
+    }
+
+    /**
+     * Create the edition at T2 if it has not already been created
+     */
+    public Person populateT2Editions(TemporalEntityManager em) {
+        em.setEffectiveTime(T2);
+        EditionSet editionSet = em.getEditionSet();
+        Assert.assertNotNull(editionSet);
+
+        Person personEditionT2 = em.find(Person.class, getSample().getId());
+
+        if (personEditionT2.getEffectivity().getStart() != T2) {
+            System.out.println("\nEditionSetTests.populateT2Edition:START");
+
+            editionSet.setDescription("EditionSetTests::Person@T2");
+            personEditionT2 = em.newEdition(personEditionT2);
+            personEditionT2.setName("Jimmy");
+            Address aT2 = em.newEdition(personEditionT2.getAddress());
+            aT2.setCity("Toronto");
+            aT2.setState("ON");
+            personEditionT2.setAddress(aT2);
+            Phone pT2 = em.newEdition(personEditionT2.getPhone("Home"));
+            personEditionT2.addPhone(pT2);
+            pT2.setNumber("222-222-2222");
+            em.persist(personEditionT2.addHobby(example.hobbies.get(GOLF), T2));
+            em.flush();
+
+            System.out.println("\nEditionSetTests.populateT2Edition::DONE");
+        }
+
+        return personEditionT2;
+    }
+
+    /**
+     * Create the edition at T2 if it has not already been created
+     */
+    public Person populateT4Editions(TemporalEntityManager em) {
+        em.setEffectiveTime(T4);
+        EditionSet editionSet = em.getEditionSet();
+        Assert.assertNotNull(editionSet);
+
+        Person personEditionT4 = em.find(Person.class, getSample().getId());
+
+        if (personEditionT4.getEffectivity().getStart() != T4) {
+            System.out.println("\nEditionSetTests.populateT4Edition:START");
+
+            editionSet.setDescription("EditionSetTests::Person@T4");
+            personEditionT4 = em.newEdition(personEditionT4);
+            personEditionT4.setName("Jimbo");
+            Address aT4 = em.newEdition(personEditionT4.getAddress());
+            aT4.setCity("Ottawa");
+            personEditionT4.setAddress(aT4);
+            Phone pT4 = em.newEdition(personEditionT4.getPhone("Home"));
+            personEditionT4.addPhone(pT4);
+            pT4.setNumber("444-444-4444");
+            em.persist(personEditionT4.addHobby(example.hobbies.get(RUN), T4));
+            em.flush();
+
+            System.out.println("\nEditionSetTests.populateT4Edition::DONE");
+        }
+
+        return personEditionT4;
+    }
+}