/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj) { StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); } }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * This method makes sure we don't already have the instance cached */ protected void checkForDuplicateId(Object id, Object obj, ClassMetaData meta) { FieldMetaData[] pks = meta.getPrimaryKeyFields(); if (pks != null && pks.length == 1 && pks[0].getValueStrategy() == ValueStrategies.AUTOASSIGN) { return; } StateManagerImpl other = getStateManagerImplById(id, false); if (other != null && !other.isDeleted() && !other.isNew()) throw new ObjectExistsException(_loc.get("cache-exists", obj.getClass().getName(), id)).setFailedObject(obj); }
/** * Narrows the given SQLException to a specific type of * {@link StoreException#getSubtype() StoreException} by analyzing the * SQLState code supplied by SQLException. Each database-specific * {@link DBDictionary dictionary} can supply a set of error codes that will * map to a specific specific type of StoreException via * {@link DBDictionary#getSQLStates(int) getSQLStates()} method. * The default behavior is to return generic {@link StoreException * StoreException}. */ public static OpenJPAException narrow(String msg, SQLException se, DBDictionary dict) { String e = se.getSQLState(); if (dict.getSQLStates(StoreException.LOCK).contains(e)) return new LockException(msg); else if (dict.getSQLStates(StoreException.OBJECT_EXISTS).contains(e)) return new ObjectExistsException(msg); else if (dict.getSQLStates(StoreException.OBJECT_NOT_FOUND).contains(e)) return new ObjectNotFoundException(msg); else if (dict.getSQLStates(StoreException.OPTIMISTIC).contains(e)) return new OptimisticException(msg); else if (dict.getSQLStates(StoreException.REFERENTIAL_INTEGRITY) .contains(e)) return new ReferentialIntegrityException(msg); else return new StoreException(msg); } }
break; case StoreException.OBJECT_EXISTS: storeEx = new ObjectExistsException(msg); break; case StoreException.OBJECT_NOT_FOUND:
break; case StoreException.OBJECT_EXISTS: storeEx = new ObjectExistsException(msg); break; case StoreException.OBJECT_NOT_FOUND:
break; case StoreException.OBJECT_EXISTS: storeEx = new ObjectExistsException(msg); break; case StoreException.OBJECT_NOT_FOUND:
break; case StoreException.OBJECT_EXISTS: storeEx = new ObjectExistsException(msg); break; case StoreException.OBJECT_NOT_FOUND:
if (sm != null) { if (sm.isDetached()) throw new ObjectExistsException(_loc.get ("persist-detached", Exceptions.toString(obj))). setFailedObject(obj); pc = assertPersistenceCapable(obj); if (pc.pcIsDetached() == Boolean.TRUE) throw new ObjectExistsException(_loc.get ("persist-detached", Exceptions.toString(obj))). setFailedObject(obj);
if (sm != null) { if (sm.isDetached()) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj); pc = assertPersistenceCapable(obj); if (pc.pcIsDetached() == Boolean.TRUE) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj);
if (sm != null) { if (sm.isDetached()) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj); pc = assertPersistenceCapable(obj); if (pc.pcIsDetached() == Boolean.TRUE) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj);
if (sm != null) { if (sm.isDetached()) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj); pc = assertPersistenceCapable(obj); if (pc.pcIsDetached() == Boolean.TRUE) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj);
if (sm != null) { if (sm.isDetached()) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj); pc = assertPersistenceCapable(obj); if (pc.pcIsDetached() == Boolean.TRUE) { throw new ObjectExistsException(_loc.get("persist-detached", Exceptions.toString(obj))) .setFailedObject(obj);