/**
* This testcase was added for OPENJPA-1400.
*/
public void testPersistRelationshipToDetchedEntityZeroVersion() {
OpenJPAEntityManagerSPI em = emf.createEntityManager();
NoDetachedStateEntityPropertyAccess property = em.find(NoDetachedStateEntityPropertyAccess.class, 1);
em.close();
// Make sure we don't hit any exceptions when persisting a relationship to a detached
// entity.
em = emf.createEntityManager();
em.getTransaction().begin();
NoDetachedStateEntityFieldAccess field = em.find(NoDetachedStateEntityFieldAccess.class, 1);
field.setRelationship(property);
em.getTransaction().commit();
em.close();
// Make sure that the relationship was persisted
em = emf.createEntityManager();
field = em.find(NoDetachedStateEntityFieldAccess.class, 1);
property = field.getRelationship();
assertNotNull(property);
assertEquals(1, property.getId());
}