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.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
@ -510,13 +510,17 @@ public class DataCacheStoreManager
|
|||
for (Iterator itr = states.iterator(); itr.hasNext();) {
|
||||
sm = (OpenJPAStateManager) itr.next();
|
||||
|
||||
if (sm.getPCState() == PCState.PNEW) {
|
||||
if (sm.getPCState() == PCState.PNEW && !sm.isFlushed()) {
|
||||
if (_inserts == null)
|
||||
_inserts = new LinkedList();
|
||||
_inserts = new ArrayList();
|
||||
_inserts.add(sm);
|
||||
} else if (_inserts != null &&
|
||||
(sm.getPCState() == PCState.PNEWDELETED ||
|
||||
sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
|
||||
|
||||
// may have been re-persisted
|
||||
if (_deletes != null)
|
||||
_deletes.remove(sm);
|
||||
} else if (_inserts != null
|
||||
&& (sm.getPCState() == PCState.PNEWDELETED
|
||||
|| sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
|
||||
_inserts.remove(sm);
|
||||
else if (sm.getPCState() == PCState.PDIRTY) {
|
||||
if (_updates == null)
|
||||
|
@ -524,7 +528,7 @@ public class DataCacheStoreManager
|
|||
_updates.put(sm, sm.getDirty());
|
||||
} else if (sm.getPCState() == PCState.PDELETED) {
|
||||
if (_deletes == null)
|
||||
_deletes = new LinkedList();
|
||||
_deletes = new HashSet();
|
||||
_deletes.add(sm);
|
||||
}
|
||||
}
|
||||
|
@ -572,10 +576,10 @@ public class DataCacheStoreManager
|
|||
*/
|
||||
private static class Modifications {
|
||||
|
||||
public final List additions = new LinkedList();
|
||||
public final List newUpdates = new LinkedList();
|
||||
public final List existingUpdates = new LinkedList();
|
||||
public final List deletes = new LinkedList();
|
||||
public final List additions = new ArrayList();
|
||||
public final List newUpdates = new ArrayList();
|
||||
public final List existingUpdates = new ArrayList();
|
||||
public final List deletes = new ArrayList();
|
||||
}
|
||||
|
||||
private static class PCDataHolder {
|
||||
|
|
|
@ -259,20 +259,17 @@ public class DetachManager
|
|||
* Return a detached version of the given instance.
|
||||
*/
|
||||
public Object detach(Object toDetach) {
|
||||
CallbackException excep = null;
|
||||
List exceps = null;
|
||||
try {
|
||||
return detachInternal(toDetach);
|
||||
} catch (CallbackException ce) {
|
||||
excep = ce;
|
||||
exceps = new ArrayList(1);
|
||||
exceps.add(ce);
|
||||
return null; // won't be reached as exception will be rethrown
|
||||
} finally {
|
||||
List exceps = null;
|
||||
|
||||
if (excep == null || !_failFast) {
|
||||
if (exceps == null || !_failFast)
|
||||
exceps = invokeAfterDetach(Collections.singleton(toDetach),
|
||||
null);
|
||||
} else
|
||||
exceps = Collections.singletonList(excep);
|
||||
exceps);
|
||||
if (_detached != null)
|
||||
_detached.clear();
|
||||
throwExceptions(exceps);
|
||||
|
@ -303,11 +300,8 @@ public class DetachManager
|
|||
failFast = true;
|
||||
exceps = add(exceps, re);
|
||||
} finally {
|
||||
// invoke post callbacks unless all failed
|
||||
if (!failFast && (exceps == null
|
||||
|| exceps.size() < instances.size())) {
|
||||
if (!failFast)
|
||||
exceps = invokeAfterDetach(instances, exceps);
|
||||
}
|
||||
if (_detached != null)
|
||||
_detached.clear();
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ class SingleFieldManager
|
|||
if (proxy == null) {
|
||||
proxy = (Proxy) _sm.newFieldProxy(field);
|
||||
((Date) proxy).setTime(((Date) objval).getTime());
|
||||
if (proxy instanceof Timestamp &&
|
||||
objval instanceof Timestamp)
|
||||
if (proxy instanceof Timestamp
|
||||
&& objval instanceof Timestamp)
|
||||
((Timestamp) proxy).setNanos(((Timestamp) objval).
|
||||
getNanos());
|
||||
ret = true;
|
||||
|
@ -89,12 +89,7 @@ class SingleFieldManager
|
|||
proxy = checkProxy();
|
||||
if (proxy == null) {
|
||||
proxy = (Proxy) _sm.newFieldProxy(field);
|
||||
if (objval != null) {
|
||||
Calendar pcal = (Calendar) proxy;
|
||||
Calendar ocal = (Calendar) objval;
|
||||
pcal.setTime(ocal.getTime());
|
||||
pcal.setTimeZone(ocal.getTimeZone());
|
||||
}
|
||||
((Calendar) proxy).setTime(((Calendar) objval).getTime());
|
||||
ret = true;
|
||||
}
|
||||
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);
|
||||
|
||||
private int _access = ClassMetaData.ACCESS_FIELD;
|
||||
private int _identity = ClassMetaData.ID_UNKNOWN;
|
||||
private boolean _ignore = true;
|
||||
private boolean _interface = true;
|
||||
private boolean _pcRegistry = true;
|
||||
|
@ -63,18 +64,34 @@ public abstract class AbstractMetaDataDefaults
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
_access = access;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default access type for base classes with ACCESS_UNKNOWN.
|
||||
* Returns ACCESS_FIELD by default.
|
||||
* The default identity type for unmapped classes without primary
|
||||
* key fields. ID_UNKNOWN by default.
|
||||
*/
|
||||
public int getDefaultAccessType() {
|
||||
return _access;
|
||||
public int getDefaultIdentityType() {
|
||||
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() {
|
||||
|
|
|
@ -379,12 +379,13 @@ public class ClassMetaData
|
|||
ClassMetaData sup = getPCSuperclassMetaData();
|
||||
if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
|
||||
_identity = sup.getIdentityType();
|
||||
else {
|
||||
if (getPrimaryKeyFields().length > 0)
|
||||
_identity = ID_APPLICATION;
|
||||
else
|
||||
_identity = (isMapped()) ? ID_DATASTORE : ID_UNKNOWN;
|
||||
}
|
||||
else if (getPrimaryKeyFields().length > 0)
|
||||
_identity = ID_APPLICATION;
|
||||
else if (isMapped())
|
||||
_identity = ID_DATASTORE;
|
||||
else
|
||||
_identity = _repos.getMetaDataFactory().getDefaults().
|
||||
getDefaultIdentityType();
|
||||
}
|
||||
return _identity;
|
||||
}
|
||||
|
|
|
@ -28,11 +28,17 @@ public interface MetaDataDefaults
|
|||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -1377,8 +1377,6 @@ public class MetaDataRepository
|
|||
* Update the list of implementations of base classes and interfaces.
|
||||
*/
|
||||
private void updateImpls(Class cls, Class leastDerived, Class check) {
|
||||
if (!_factory.getDefaults().isDeclaredInterfacePersistent())
|
||||
return;
|
||||
// allow users to query on common non-pc superclasses
|
||||
Class sup = check.getSuperclass();
|
||||
if (leastDerived == cls && sup != null && sup != Object.class) {
|
||||
|
@ -1386,6 +1384,10 @@ public class MetaDataRepository
|
|||
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();
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
// don't map java-standard interfaces
|
||||
|
|
|
@ -93,6 +93,10 @@ public class NoneMetaDataFactory
|
|||
return ClassMetaData.ACCESS_UNKNOWN;
|
||||
}
|
||||
|
||||
public int getDefaultIdentityType() {
|
||||
return ClassMetaData.ID_UNKNOWN;
|
||||
}
|
||||
|
||||
public int getCallbackMode() {
|
||||
return CALLBACK_IGNORE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue