mirror of https://github.com/apache/openjpa.git
Fixes.
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@446787 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
53dbcdf35c
commit
a7cfbfc4c9
|
@ -20,8 +20,8 @@ import java.util.BitSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -510,13 +510,17 @@ public class DataCacheStoreManager
|
||||||
for (Iterator itr = states.iterator(); itr.hasNext();) {
|
for (Iterator itr = states.iterator(); itr.hasNext();) {
|
||||||
sm = (OpenJPAStateManager) itr.next();
|
sm = (OpenJPAStateManager) itr.next();
|
||||||
|
|
||||||
if (sm.getPCState() == PCState.PNEW) {
|
if (sm.getPCState() == PCState.PNEW && !sm.isFlushed()) {
|
||||||
if (_inserts == null)
|
if (_inserts == null)
|
||||||
_inserts = new LinkedList();
|
_inserts = new ArrayList();
|
||||||
_inserts.add(sm);
|
_inserts.add(sm);
|
||||||
} else if (_inserts != null &&
|
|
||||||
(sm.getPCState() == PCState.PNEWDELETED ||
|
// may have been re-persisted
|
||||||
sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
|
if (_deletes != null)
|
||||||
|
_deletes.remove(sm);
|
||||||
|
} else if (_inserts != null
|
||||||
|
&& (sm.getPCState() == PCState.PNEWDELETED
|
||||||
|
|| sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
|
||||||
_inserts.remove(sm);
|
_inserts.remove(sm);
|
||||||
else if (sm.getPCState() == PCState.PDIRTY) {
|
else if (sm.getPCState() == PCState.PDIRTY) {
|
||||||
if (_updates == null)
|
if (_updates == null)
|
||||||
|
@ -524,7 +528,7 @@ public class DataCacheStoreManager
|
||||||
_updates.put(sm, sm.getDirty());
|
_updates.put(sm, sm.getDirty());
|
||||||
} else if (sm.getPCState() == PCState.PDELETED) {
|
} else if (sm.getPCState() == PCState.PDELETED) {
|
||||||
if (_deletes == null)
|
if (_deletes == null)
|
||||||
_deletes = new LinkedList();
|
_deletes = new HashSet();
|
||||||
_deletes.add(sm);
|
_deletes.add(sm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -572,10 +576,10 @@ public class DataCacheStoreManager
|
||||||
*/
|
*/
|
||||||
private static class Modifications {
|
private static class Modifications {
|
||||||
|
|
||||||
public final List additions = new LinkedList();
|
public final List additions = new ArrayList();
|
||||||
public final List newUpdates = new LinkedList();
|
public final List newUpdates = new ArrayList();
|
||||||
public final List existingUpdates = new LinkedList();
|
public final List existingUpdates = new ArrayList();
|
||||||
public final List deletes = new LinkedList();
|
public final List deletes = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PCDataHolder {
|
private static class PCDataHolder {
|
||||||
|
|
|
@ -259,20 +259,17 @@ public class DetachManager
|
||||||
* Return a detached version of the given instance.
|
* Return a detached version of the given instance.
|
||||||
*/
|
*/
|
||||||
public Object detach(Object toDetach) {
|
public Object detach(Object toDetach) {
|
||||||
CallbackException excep = null;
|
List exceps = null;
|
||||||
try {
|
try {
|
||||||
return detachInternal(toDetach);
|
return detachInternal(toDetach);
|
||||||
} catch (CallbackException ce) {
|
} catch (CallbackException ce) {
|
||||||
excep = ce;
|
exceps = new ArrayList(1);
|
||||||
|
exceps.add(ce);
|
||||||
return null; // won't be reached as exception will be rethrown
|
return null; // won't be reached as exception will be rethrown
|
||||||
} finally {
|
} finally {
|
||||||
List exceps = null;
|
if (exceps == null || !_failFast)
|
||||||
|
|
||||||
if (excep == null || !_failFast) {
|
|
||||||
exceps = invokeAfterDetach(Collections.singleton(toDetach),
|
exceps = invokeAfterDetach(Collections.singleton(toDetach),
|
||||||
null);
|
exceps);
|
||||||
} else
|
|
||||||
exceps = Collections.singletonList(excep);
|
|
||||||
if (_detached != null)
|
if (_detached != null)
|
||||||
_detached.clear();
|
_detached.clear();
|
||||||
throwExceptions(exceps);
|
throwExceptions(exceps);
|
||||||
|
@ -303,11 +300,8 @@ public class DetachManager
|
||||||
failFast = true;
|
failFast = true;
|
||||||
exceps = add(exceps, re);
|
exceps = add(exceps, re);
|
||||||
} finally {
|
} finally {
|
||||||
// invoke post callbacks unless all failed
|
if (!failFast)
|
||||||
if (!failFast && (exceps == null
|
|
||||||
|| exceps.size() < instances.size())) {
|
|
||||||
exceps = invokeAfterDetach(instances, exceps);
|
exceps = invokeAfterDetach(instances, exceps);
|
||||||
}
|
|
||||||
if (_detached != null)
|
if (_detached != null)
|
||||||
_detached.clear();
|
_detached.clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,8 @@ class SingleFieldManager
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = (Proxy) _sm.newFieldProxy(field);
|
proxy = (Proxy) _sm.newFieldProxy(field);
|
||||||
((Date) proxy).setTime(((Date) objval).getTime());
|
((Date) proxy).setTime(((Date) objval).getTime());
|
||||||
if (proxy instanceof Timestamp &&
|
if (proxy instanceof Timestamp
|
||||||
objval instanceof Timestamp)
|
&& objval instanceof Timestamp)
|
||||||
((Timestamp) proxy).setNanos(((Timestamp) objval).
|
((Timestamp) proxy).setNanos(((Timestamp) objval).
|
||||||
getNanos());
|
getNanos());
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -89,12 +89,7 @@ class SingleFieldManager
|
||||||
proxy = checkProxy();
|
proxy = checkProxy();
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = (Proxy) _sm.newFieldProxy(field);
|
proxy = (Proxy) _sm.newFieldProxy(field);
|
||||||
if (objval != null) {
|
((Calendar) proxy).setTime(((Calendar) objval).getTime());
|
||||||
Calendar pcal = (Calendar) proxy;
|
|
||||||
Calendar ocal = (Calendar) objval;
|
|
||||||
pcal.setTime(ocal.getTime());
|
|
||||||
pcal.setTimeZone(ocal.getTimeZone());
|
|
||||||
}
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p><strong>JPA Query Language Support</strong></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Allow any spec or store to use JPQL.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -40,6 +40,7 @@ public abstract class AbstractMetaDataDefaults
|
||||||
(AbstractMetaDataDefaults.class);
|
(AbstractMetaDataDefaults.class);
|
||||||
|
|
||||||
private int _access = ClassMetaData.ACCESS_FIELD;
|
private int _access = ClassMetaData.ACCESS_FIELD;
|
||||||
|
private int _identity = ClassMetaData.ID_UNKNOWN;
|
||||||
private boolean _ignore = true;
|
private boolean _ignore = true;
|
||||||
private boolean _interface = true;
|
private boolean _interface = true;
|
||||||
private boolean _pcRegistry = true;
|
private boolean _pcRegistry = true;
|
||||||
|
@ -63,18 +64,34 @@ public abstract class AbstractMetaDataDefaults
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default access type for base classes with ACCESS_UNKNOWN.
|
* The default access type for base classes with ACCESS_UNKNOWN.
|
||||||
* Returns ACCESS_FIELD by default.
|
* ACCESS_FIELD by default.
|
||||||
|
*/
|
||||||
|
public int getDefaultAccessType() {
|
||||||
|
return _access;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default access type for base classes with ACCESS_UNKNOWN.
|
||||||
|
* ACCESS_FIELD by default.
|
||||||
*/
|
*/
|
||||||
public void setDefaultAccessType(int access) {
|
public void setDefaultAccessType(int access) {
|
||||||
_access = access;
|
_access = access;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default access type for base classes with ACCESS_UNKNOWN.
|
* The default identity type for unmapped classes without primary
|
||||||
* Returns ACCESS_FIELD by default.
|
* key fields. ID_UNKNOWN by default.
|
||||||
*/
|
*/
|
||||||
public int getDefaultAccessType() {
|
public int getDefaultIdentityType() {
|
||||||
return _access;
|
return _identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default identity type for unmapped classes without primary
|
||||||
|
* key fields. ID_UNKNOWN by default.
|
||||||
|
*/
|
||||||
|
public void setDefaultIdentityType(int identity) {
|
||||||
|
_identity = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCallbackMode() {
|
public int getCallbackMode() {
|
||||||
|
|
|
@ -379,12 +379,13 @@ public class ClassMetaData
|
||||||
ClassMetaData sup = getPCSuperclassMetaData();
|
ClassMetaData sup = getPCSuperclassMetaData();
|
||||||
if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
|
if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
|
||||||
_identity = sup.getIdentityType();
|
_identity = sup.getIdentityType();
|
||||||
else {
|
else if (getPrimaryKeyFields().length > 0)
|
||||||
if (getPrimaryKeyFields().length > 0)
|
_identity = ID_APPLICATION;
|
||||||
_identity = ID_APPLICATION;
|
else if (isMapped())
|
||||||
else
|
_identity = ID_DATASTORE;
|
||||||
_identity = (isMapped()) ? ID_DATASTORE : ID_UNKNOWN;
|
else
|
||||||
}
|
_identity = _repos.getMetaDataFactory().getDefaults().
|
||||||
|
getDefaultIdentityType();
|
||||||
}
|
}
|
||||||
return _identity;
|
return _identity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,17 @@ public interface MetaDataDefaults
|
||||||
extends CallbackModes {
|
extends CallbackModes {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the default access type for base persistent class with
|
* Return the default access type for a base persistent class with
|
||||||
* {@link ClassMetaData#ACCESS_UNKNOWN} access type.
|
* {@link ClassMetaData#ACCESS_UNKNOWN} access type.
|
||||||
*/
|
*/
|
||||||
public int getDefaultAccessType();
|
public int getDefaultAccessType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default identity type for unmapped classes without primary
|
||||||
|
* key fields.
|
||||||
|
*/
|
||||||
|
public int getDefaultIdentityType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What to do on lifecycle callback exceptions.
|
* What to do on lifecycle callback exceptions.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1377,8 +1377,6 @@ public class MetaDataRepository
|
||||||
* Update the list of implementations of base classes and interfaces.
|
* Update the list of implementations of base classes and interfaces.
|
||||||
*/
|
*/
|
||||||
private void updateImpls(Class cls, Class leastDerived, Class check) {
|
private void updateImpls(Class cls, Class leastDerived, Class check) {
|
||||||
if (!_factory.getDefaults().isDeclaredInterfacePersistent())
|
|
||||||
return;
|
|
||||||
// allow users to query on common non-pc superclasses
|
// allow users to query on common non-pc superclasses
|
||||||
Class sup = check.getSuperclass();
|
Class sup = check.getSuperclass();
|
||||||
if (leastDerived == cls && sup != null && sup != Object.class) {
|
if (leastDerived == cls && sup != null && sup != Object.class) {
|
||||||
|
@ -1386,6 +1384,10 @@ public class MetaDataRepository
|
||||||
updateImpls(cls, leastDerived, sup);
|
updateImpls(cls, leastDerived, sup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allow users to query on any implemented interfaces unless defaults
|
||||||
|
// say the user must create persistent interfaces explicitly
|
||||||
|
if (!_factory.getDefaults().isDeclaredInterfacePersistent())
|
||||||
|
return;
|
||||||
Class[] ints = check.getInterfaces();
|
Class[] ints = check.getInterfaces();
|
||||||
for (int i = 0; i < ints.length; i++) {
|
for (int i = 0; i < ints.length; i++) {
|
||||||
// don't map java-standard interfaces
|
// don't map java-standard interfaces
|
||||||
|
|
|
@ -93,6 +93,10 @@ public class NoneMetaDataFactory
|
||||||
return ClassMetaData.ACCESS_UNKNOWN;
|
return ClassMetaData.ACCESS_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDefaultIdentityType() {
|
||||||
|
return ClassMetaData.ID_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
public int getCallbackMode() {
|
public int getCallbackMode() {
|
||||||
return CALLBACK_IGNORE;
|
return CALLBACK_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue