/** * Retrieves {@link List} of entities for a given {@link Map} of embedded * column values. Purpose of this method is to provide functionality of * search based on columns inside embedded objects. * * @param entityClass * Entity Class * @param embeddedColumnMap * Embedded column map values * @return List of found entities. */ public <E> List<E> find(Class<E> entityClass, Map<String, String> embeddedColumnMap) { EntityMetadata entityMetadata = getMetadata(entityClass); // TODO Why returning entities are not added into cache we should not // iterate here but client should i think. List<E> entities = new ArrayList<E>(); entities = getClient(entityMetadata).find(entityClass, embeddedColumnMap); return entities; }
/** * Remove the given entity from the persistence context, causing a managed * entity to become detached. */ public void detach(Object entity) { Node node = getPersistenceCache().getMainCache().getNodeFromCache(entity, getMetadata(entity.getClass()), this); if (node != null) { node.detach(); } }
/** * Check if the instance is a managed entity instance belonging to the * current persistence context. */ boolean contains(Object entity) { Node node = getPersistenceCache().getMainCache().getNodeFromCache(entity, getMetadata(entity.getClass()), this); return node != null && node.isInState(ManagedState.class); }
/** * Refresh the state of the instance from the database, overwriting changes * made to the entity, if any. */ public void refresh(Object entity) { if (contains(entity)) { MainCache mainCache = (MainCache) getPersistenceCache().getMainCache(); Node node = mainCache.getNodeFromCache(entity, getMetadata(entity.getClass()), this); // Locking as it might read from persistence context. try { lock.readLock().lock(); node.setPersistenceDelegator(this); node.refresh(); } finally { lock.readLock().unlock(); } } else { throw new IllegalArgumentException("This is not a valid or managed entity, can't be refreshed"); } }
EntityMetadata m = getMetadata(e.getClass());
EntityMetadata metadata = getMetadata(e.getClass());
EntityMetadata entityMetadata = getMetadata(entityClass);
EntityMetadata metadata = getMetadata(node.getDataClass()); node.setClient(getClient(metadata));