@Override public Image updateImpl(com.liferay.portal.model.Image image) throws SystemException { image = toUnwrappedModel(image); boolean isNew = image.isNew(); Session session = null; try { session = openSession(); if (image.isNew()) { session.save(image); image.setNew(false); } else { session.merge(image); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ImageModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } EntityCacheUtil.putResult( ImageModelImpl.ENTITY_CACHE_ENABLED, ImageImpl.class, image.getPrimaryKey(), image); return image; }
/** * Clears the cache for the image. * * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. */ @Override public void clearCache(Image image) { EntityCacheUtil.removeResult( ImageModelImpl.ENTITY_CACHE_ENABLED, ImageImpl.class, image.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); }
/** * Caches the images in the entity cache if it is enabled. * * @param images the images */ public void cacheResult(List<Image> images) { for (Image image : images) { if (EntityCacheUtil.getResult( ImageModelImpl.ENTITY_CACHE_ENABLED, ImageImpl.class, image.getPrimaryKey()) == null) { cacheResult(image); } else { image.resetOriginalValues(); } } }
protected Image toUnwrappedModel(Image image) { if (image instanceof ImageImpl) { return image; } ImageImpl imageImpl = new ImageImpl(); imageImpl.setNew(image.isNew()); imageImpl.setPrimaryKey(image.getPrimaryKey()); imageImpl.setImageId(image.getImageId()); imageImpl.setModifiedDate(image.getModifiedDate()); imageImpl.setText(image.getText()); imageImpl.setType(image.getType()); imageImpl.setHeight(image.getHeight()); imageImpl.setWidth(image.getWidth()); imageImpl.setSize(image.getSize()); return imageImpl; }
public boolean equals(Object obj) { if (obj == null) { return false; } Image image = null; try { image = (Image) obj; } catch (ClassCastException cce) { return false; } long pk = image.getPrimaryKey(); if (getPrimaryKey() == pk) { return true; } else { return false; } }
/** * Caches the image in the entity cache if it is enabled. * * @param image the image */ public void cacheResult(Image image) { EntityCacheUtil.putResult( ImageModelImpl.ENTITY_CACHE_ENABLED, ImageImpl.class, image.getPrimaryKey(), image); image.resetOriginalValues(); }