@Test public void testFetchByPrimaryKeyExisting() throws Exception { Release newRelease = addRelease(); Release existingRelease = _persistence.fetchByPrimaryKey(newRelease.getPrimaryKey()); Assert.assertEquals(existingRelease, newRelease); }
@Test public void testCreate() throws Exception { long pk = ServiceTestUtil.nextLong(); Release release = _persistence.create(pk); Assert.assertNotNull(release); Assert.assertEquals(release.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { Release newRelease = addRelease(); _persistence.remove(newRelease); Release existingRelease = _persistence.fetchByPrimaryKey(newRelease.getPrimaryKey()); Assert.assertNull(existingRelease); }
/** * Clears the cache for the release. * * <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(Release release) { EntityCacheUtil.removeResult( ReleaseModelImpl.ENTITY_CACHE_ENABLED, ReleaseImpl.class, release.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache(release); }
public int compareTo(Release release) { long primaryKey = release.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
/** * Caches the releases in the entity cache if it is enabled. * * @param releases the releases */ public void cacheResult(List<Release> releases) { for (Release release : releases) { if (EntityCacheUtil.getResult( ReleaseModelImpl.ENTITY_CACHE_ENABLED, ReleaseImpl.class, release.getPrimaryKey()) == null) { cacheResult(release); } else { release.resetOriginalValues(); } } }
/** * Caches the release in the entity cache if it is enabled. * * @param release the release */ public void cacheResult(Release release) { EntityCacheUtil.putResult( ReleaseModelImpl.ENTITY_CACHE_ENABLED, ReleaseImpl.class, release.getPrimaryKey(), release); FinderCacheUtil.putResult( FINDER_PATH_FETCH_BY_SERVLETCONTEXTNAME, new Object[] {release.getServletContextName()}, release); release.resetOriginalValues(); }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); Release newRelease = _persistence.create(pk); newRelease.setMvccVersion(ServiceTestUtil.nextLong()); newRelease.setCreateDate(ServiceTestUtil.nextDate()); newRelease.setModifiedDate(ServiceTestUtil.nextDate()); newRelease.setServletContextName(ServiceTestUtil.randomString()); newRelease.setBuildNumber(ServiceTestUtil.nextInt()); newRelease.setBuildDate(ServiceTestUtil.nextDate()); newRelease.setVerified(ServiceTestUtil.randomBoolean()); newRelease.setState(ServiceTestUtil.nextInt()); newRelease.setTestString(ServiceTestUtil.randomString()); _persistence.update(newRelease); Release existingRelease = _persistence.findByPrimaryKey(newRelease.getPrimaryKey()); Assert.assertEquals(existingRelease.getMvccVersion(), newRelease.getMvccVersion()); Assert.assertEquals(existingRelease.getReleaseId(), newRelease.getReleaseId()); Assert.assertEquals( Time.getShortTimestamp(existingRelease.getCreateDate()), Time.getShortTimestamp(newRelease.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingRelease.getModifiedDate()), Time.getShortTimestamp(newRelease.getModifiedDate())); Assert.assertEquals( existingRelease.getServletContextName(), newRelease.getServletContextName()); Assert.assertEquals(existingRelease.getBuildNumber(), newRelease.getBuildNumber()); Assert.assertEquals( Time.getShortTimestamp(existingRelease.getBuildDate()), Time.getShortTimestamp(newRelease.getBuildDate())); Assert.assertEquals(existingRelease.getVerified(), newRelease.getVerified()); Assert.assertEquals(existingRelease.getState(), newRelease.getState()); Assert.assertEquals(existingRelease.getTestString(), newRelease.getTestString()); }
@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } Release newRelease = addRelease(); _persistence.clearCache(); ReleaseModelImpl existingReleaseModelImpl = (ReleaseModelImpl) _persistence.findByPrimaryKey(newRelease.getPrimaryKey()); Assert.assertTrue( Validator.equals( existingReleaseModelImpl.getServletContextName(), existingReleaseModelImpl.getOriginalServletContextName())); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } Release release = null; try { release = (Release) obj; } catch (ClassCastException cce) { return false; } long primaryKey = release.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
protected Release toUnwrappedModel(Release release) { if (release instanceof ReleaseImpl) { return release; } ReleaseImpl releaseImpl = new ReleaseImpl(); releaseImpl.setNew(release.isNew()); releaseImpl.setPrimaryKey(release.getPrimaryKey()); releaseImpl.setReleaseId(release.getReleaseId()); releaseImpl.setCreateDate(release.getCreateDate()); releaseImpl.setModifiedDate(release.getModifiedDate()); releaseImpl.setServletContextName(release.getServletContextName()); releaseImpl.setBuildNumber(release.getBuildNumber()); releaseImpl.setBuildDate(release.getBuildDate()); releaseImpl.setVerified(release.isVerified()); releaseImpl.setState(release.getState()); releaseImpl.setTestString(release.getTestString()); return releaseImpl; }
@Override public Release updateImpl(com.liferay.portal.model.Release release) throws SystemException { release = toUnwrappedModel(release); boolean isNew = release.isNew(); Session session = null; try { session = openSession(); if (release.isNew()) { session.save(release); release.setNew(false); } else { session.merge(release); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !ReleaseModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } EntityCacheUtil.putResult( ReleaseModelImpl.ENTITY_CACHE_ENABLED, ReleaseImpl.class, release.getPrimaryKey(), release); clearUniqueFindersCache(release); cacheUniqueFindersCache(release); return release; }