/** * Returns true if this persistence context contains an entity retrievable by * the given key. The type matching is done in the same way as described in * {@link #get(Key)}. * * @param key * the identity of the entity to look for. Must not be null. * @return True if and only if this persistence context contains an entity * retrievable by the given key. */ public boolean contains(Key<?, ?> key) { return get(key) != null; }
@Override public boolean contains(final Object entity) { final Object found = persistenceContext.get(keyFor(entity)); return found == entity; }
Object inPersistenceContext = persistenceContext.get(key); while (inPersistenceContext instanceof WrappedPortable) { inPersistenceContext = ((WrappedPortable) inPersistenceContext).unwrap();
/** * Retrieves the entity instance identified by the given Key. * * @param key The key to look up. Must not be null. * @param properties JPA hints (standard and Errai-specific) for the lookup. * @return the entity instance, or null if the entity cannot be found. */ public <X> X find(final Key<X, ?> key, final Map<String, Object> properties) { X entity = cast(key.getEntityType().getJavaType(), persistenceContext.get(key)); if (entity == null) { entity = backend.get(key); if (entity != null) { persistenceContext.put(key, entity); ((ErraiIdentifiableType<X>) key.getEntityType()).deliverPostLoad(entity); } } return entity; }