OpenJPA-1610: Changed two methods (one name change, one signature change) to allow applications using OpenJPA 1.x to run with the JPA 2.0 jar on the classpath after recompiling the applications and correcting any use of the two methods that have changed.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.1.x@930357 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Ezzio 2010-04-02 19:38:58 +00:00
parent e910221a63
commit e6104b82b9
16 changed files with 6474 additions and 6457 deletions

View File

@ -1387,7 +1387,7 @@ public abstract class CacheTest extends AbstractTestCase {
CacheObjectA a = (CacheObjectA) c.iterator().next();
if (related)
a.getRelatedArray();
em.detach(a);
em.detachCopy(a);
assertEquals(ORIG_NAME, a.getName());
q.closeAll();
}

View File

@ -56,7 +56,7 @@ public class NonstandardMappingEntity
joinColumns = @XJoinColumn(name = "OWNER"),
joinIndex = @Index(enabled = false))
@ElementColumn(name = "STR_ELEM", length = 127)
@OrderColumn(name = "ORDER_COL")
@org.apache.openjpa.persistence.jdbc.OrderColumn(name = "ORDER_COL")
@ElementIndex
private List stringCollection = new ArrayList();

View File

@ -92,7 +92,7 @@ public class TestCalendarFields extends BaseKernelTest {
pm = getPM();
c2 = (CalendarFields) pm.find(CalendarFields.class, id2);
assertTimeZonesEquals(c1, c2);
assertTimeZonesEquals(c1, (CalendarFields) pm.detach(c2));
assertTimeZonesEquals(c1, (CalendarFields) pm.detachCopy(c2));
endEm(pm);
}

View File

@ -531,7 +531,7 @@ public class TestDependentFields2 extends BaseKernelTest {
assertEquals(2, owner.getDependentMappedList().size());
else
assertEquals(2, owner.getDependentInverseKeyList().size());
DependentFieldsPC detached = (DependentFieldsPC) pm.detach(owner);
DependentFieldsPC detached = (DependentFieldsPC) pm.detachCopy(owner);
endEm(pm);
if (mapped) {

View File

@ -104,7 +104,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("b is null in testDetach", b);
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
assertTrue(pm.isDetached(b));
@ -147,7 +147,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("b is null in testDetachWithGroups", b);
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
assertTrue(pm.isDetached(b));
@ -186,7 +186,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
public void testDetachNoOverwrite() {
OpenJPAEntityManager pm = getPM();
AttachB b = (AttachB) pm.find(AttachB.class, oid);
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
b.setBstr("12");
@ -216,7 +216,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("b is null in testOptimisticLock", b);
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
b.setAint(12);
@ -251,7 +251,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("d is null in testEmbedded", d);
d.getEmbeddedE().getEstr();
d = (AttachD) pm.detach(d);
d = (AttachD) pm.detachCopy(d);
endEm(pm);
d.getEmbeddedE().setEstr("E12");
@ -280,7 +280,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("d is null in testNullEmbedded", d);
d.getEmbeddedE().getEstr();
d = (AttachD) pm.detach(d);
d = (AttachD) pm.detachCopy(d);
endEm(pm);
d.setEmbeddedE(null);
@ -310,7 +310,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("d is null in testNullEmbeddedRelated", d);
d.getEmbeddedE().getEstr();
d = (AttachD) pm.detach(d);
d = (AttachD) pm.detachCopy(d);
endEm(pm);
d.getEmbeddedE().setEstr(null);
@ -337,7 +337,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
OpenJPAEntityManager pm = getPM();
AttachB b = (AttachB) pm.find(AttachB.class, oid);
b.getDs();
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
assertEquals(1, b.getDs().size());
@ -370,7 +370,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
assertNotNull("b is null in doCollectionTest", b);
b.getDs();
b = (AttachB) pm.detach(b);
b = (AttachB) pm.detachCopy(b);
endEm(pm);
assertEquals("b is null in doCollectionTest", 1, b.getDs().size());
@ -465,7 +465,7 @@ public class TestDetachedStateManager extends BaseKernelTest {
pc.getRelSet();
pc.getStringIntMap();
if (!auto) {
pc = (DetachSMPC) pm.detach(pc);
pc = (DetachSMPC) pm.detachCopy(pc);
assertDetachedSM(pc);
}
pc = (DetachSMPC) roundtrip(pc, false);

View File

@ -431,7 +431,7 @@ public class TestFetchPlan extends BaseKernelTest {
PCCompany company1 =
(PCCompany) pm.find(PCCompany.class, _rootCompanyId);
PCCompany company = (PCCompany) pm.detach(company1);
PCCompany company = (PCCompany) pm.detachCopy(company1);
assertTrue("company is equal company1", company != company1);
Set departments = (Set) PCCompany.reflect(company, "departments");
assertNotNull("department is null", departments);

View File

@ -224,7 +224,7 @@ public class TestOptimisticLockGroups extends BaseKernelTest {
throws Exception {
OpenJPAEntityManager pm1 = getPM(false, false);
LockGroupPC pc1 = (LockGroupPC) pm1.find(LockGroupPC.class, oid);
Object detached = pm1.detach(pc1);
Object detached = pm1.detachCopy(pc1);
startTx(pm1);
pc1.setLockGroup0IntField(1);
pc1.setUnlockedStringField("pm1 changed value");
@ -259,7 +259,7 @@ public class TestOptimisticLockGroups extends BaseKernelTest {
throws Exception {
OpenJPAEntityManager pm1 = getPM(false, false);
LockGroupPC pc1 = (LockGroupPC) pm1.find(LockGroupPC.class, oid);
Object detached = pm1.detach(pc1);
Object detached = pm1.detachCopy(pc1);
startTx(pm1);
pc1.setLockGroup0IntField(1);
endTx(pm1);

View File

@ -187,7 +187,7 @@ public class TestPersistenceManagerFactoryImpl extends BaseKernelTest {
public void testPlatform() {
OpenJPAEntityManagerFactory pmf =
(OpenJPAEntityManagerFactory) getEmf();
assertNotNull(pmf.getProperties().getProperty("Platform"));
assertNotNull(pmf.getProperties().get("Platform"));
}
protected OpenJPAEntityManagerFactory getEmf(Map props) {

View File

@ -437,7 +437,7 @@ public class TestManagedInterfaces extends SingleEMFTestCase {
em = emf.createEntityManager();
ManagedIface pcx = em.find(ManagedIface.class, oid);
pc = em.detach(pcx);
pc = em.detachCopy(pcx);
em.close();
assertTrue(em.isDetached(pc));

View File

@ -301,8 +301,8 @@ public class TestValueStrategies
endTx(pm);
assertEquals(2, pc.getVersion());
assertEquals(2, pc2.getVersion());
ValueStrategyPC detached = (ValueStrategyPC) pm.detach(pc);
ValueStrategyPC detached2 = (ValueStrategyPC) pm.detach(pc2);
ValueStrategyPC detached = (ValueStrategyPC) pm.detachCopy(pc);
ValueStrategyPC detached2 = (ValueStrategyPC) pm.detachCopy(pc2);
endEm(pm);
// clean attach

View File

@ -79,7 +79,7 @@ public class TestLRS
OpenJPAEntityManager em = emf.createEntityManager();
LRSEntity lrs = em.find(LRSEntity.class, id);
assertLRS(lrs, "lrs");
lrs = em.detach(lrs);
lrs = em.detachCopy(lrs);
assertEquals("lrs", lrs.getName());
assertNull(lrs.getLRSList());
em.close();

View File

@ -73,7 +73,7 @@ public class TestFlushBeforeDetach extends SQLListenerTestCase {
i.setItemData("EFGH");
OpenJPAPersistence.cast(em).detach(i);
OpenJPAPersistence.cast(em).detachCopy(i);
em.getTransaction().rollback();
assertNotSQL("UPDATE ITEM SET.*");
em.close();

View File

@ -97,10 +97,17 @@ public class EntityManagerFactoryImpl
return _factory.getConfiguration();
}
public Properties getProperties() {
public Properties getPropertiesAsProperties() {
return _factory.getProperties();
}
public Map<String, Object> getProperties() {
@SuppressWarnings("unchecked")
HashMap<String, Object> retv =
new HashMap<String, Object>((Map) getPropertiesAsProperties());
return retv;
}
public Object putUserObject(Object key, Object val) {
return _factory.putUserObject(key, val);
}

View File

@ -748,7 +748,7 @@ public class EntityManagerImpl
}
@SuppressWarnings("unchecked")
public <T> T detach(T entity) {
public <T> T detachCopy(T entity) {
assertNotCloseInvoked();
return (T) _broker.detach(entity, this);
}

View File

@ -535,10 +535,12 @@ public interface OpenJPAEntityManager
/**
* Detach the specified object from the entity manager.
*
* Note: renamed from detach to avoid conflict with JPA 2.0 EntityManager.detach method
*
* @param pc the instance to detach
* @return the detached instance
*/
public <T> T detach(T pc);
public <T> T detachCopy(T pc);
/**
* Detach the specified objects from the entity manager.

View File

@ -35,8 +35,16 @@ public interface OpenJPAEntityManagerFactory
/**
* Return properties describing this runtime.
* Although the name has changed, this method
* returns the same type as the old getProperties method.
*/
public Properties getProperties();
public Properties getPropertiesAsProperties();
/**
* Returns properties describing this runtime
* using new signature to avoid conflict with JPA 2.0 API
*/
public Map<String, Object> getProperties();
/**
* Put the specified key-value pair into the map of user objects.