@Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    OrgLabor newOrgLabor = addOrgLabor();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newOrgLabor.getPrimaryKey());

    Map<Serializable, OrgLabor> orgLabors = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, orgLabors.size());
    Assert.assertEquals(newOrgLabor, orgLabors.get(newOrgLabor.getPrimaryKey()));
  }
  protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
    if (orgLabor instanceof OrgLaborImpl) {
      return orgLabor;
    }

    OrgLaborImpl orgLaborImpl = new OrgLaborImpl();

    orgLaborImpl.setNew(orgLabor.isNew());
    orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());

    orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
    orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
    orgLaborImpl.setTypeId(orgLabor.getTypeId());
    orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
    orgLaborImpl.setSunClose(orgLabor.getSunClose());
    orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
    orgLaborImpl.setMonClose(orgLabor.getMonClose());
    orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
    orgLaborImpl.setTueClose(orgLabor.getTueClose());
    orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
    orgLaborImpl.setWedClose(orgLabor.getWedClose());
    orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
    orgLaborImpl.setThuClose(orgLabor.getThuClose());
    orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
    orgLaborImpl.setFriClose(orgLabor.getFriClose());
    orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
    orgLaborImpl.setSatClose(orgLabor.getSatClose());

    return orgLaborImpl;
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    OrgLabor newOrgLabor = addOrgLabor();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newOrgLabor.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, OrgLabor> orgLabors = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, orgLabors.size());
    Assert.assertEquals(newOrgLabor, orgLabors.get(newOrgLabor.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    OrgLabor newOrgLabor1 = addOrgLabor();
    OrgLabor newOrgLabor2 = addOrgLabor();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newOrgLabor1.getPrimaryKey());
    primaryKeys.add(newOrgLabor2.getPrimaryKey());

    Map<Serializable, OrgLabor> orgLabors = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, orgLabors.size());
    Assert.assertEquals(newOrgLabor1, orgLabors.get(newOrgLabor1.getPrimaryKey()));
    Assert.assertEquals(newOrgLabor2, orgLabors.get(newOrgLabor2.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    OrgLabor newOrgLabor = addOrgLabor();

    OrgLabor existingOrgLabor = _persistence.fetchByPrimaryKey(newOrgLabor.getPrimaryKey());

    Assert.assertEquals(existingOrgLabor, newOrgLabor);
  }
  /**
   * Clears the cache for the org labor.
   *
   * <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(OrgLabor orgLabor) {
    EntityCacheUtil.removeResult(
        OrgLaborModelImpl.ENTITY_CACHE_ENABLED, OrgLaborImpl.class, orgLabor.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }
  /**
   * Caches the org labor in the entity cache if it is enabled.
   *
   * @param orgLabor the org labor
   */
  public void cacheResult(OrgLabor orgLabor) {
    EntityCacheUtil.putResult(
        OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
        OrgLaborImpl.class,
        orgLabor.getPrimaryKey(),
        orgLabor);

    orgLabor.resetOriginalValues();
  }
  @Test
  public void testRemove() throws Exception {
    OrgLabor newOrgLabor = addOrgLabor();

    _persistence.remove(newOrgLabor);

    OrgLabor existingOrgLabor = _persistence.fetchByPrimaryKey(newOrgLabor.getPrimaryKey());

    Assert.assertNull(existingOrgLabor);
  }
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    OrgLabor orgLabor = _persistence.create(pk);

    Assert.assertNotNull(orgLabor);

    Assert.assertEquals(orgLabor.getPrimaryKey(), pk);
  }
  @Override
  public OrgLabor updateImpl(com.liferay.portal.model.OrgLabor orgLabor) throws SystemException {
    orgLabor = toUnwrappedModel(orgLabor);

    boolean isNew = orgLabor.isNew();

    OrgLaborModelImpl orgLaborModelImpl = (OrgLaborModelImpl) orgLabor;

    Session session = null;

    try {
      session = openSession();

      if (orgLabor.isNew()) {
        session.save(orgLabor);

        orgLabor.setNew(false);
      } else {
        session.merge(orgLabor);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !OrgLaborModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((orgLaborModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {Long.valueOf(orgLaborModelImpl.getOriginalOrganizationId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID, args);

        args = new Object[] {Long.valueOf(orgLaborModelImpl.getOrganizationId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ORGANIZATIONID, args);
      }
    }

    EntityCacheUtil.putResult(
        OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
        OrgLaborImpl.class,
        orgLabor.getPrimaryKey(),
        orgLabor);

    return orgLabor;
  }
 /**
  * Caches the org labors in the entity cache if it is enabled.
  *
  * @param orgLabors the org labors
  */
 public void cacheResult(List<OrgLabor> orgLabors) {
   for (OrgLabor orgLabor : orgLabors) {
     if (EntityCacheUtil.getResult(
             OrgLaborModelImpl.ENTITY_CACHE_ENABLED, OrgLaborImpl.class, orgLabor.getPrimaryKey())
         == null) {
       cacheResult(orgLabor);
     } else {
       orgLabor.resetOriginalValues();
     }
   }
 }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    OrgLabor newOrgLabor = _persistence.create(pk);

    newOrgLabor.setMvccVersion(RandomTestUtil.nextLong());

    newOrgLabor.setCompanyId(RandomTestUtil.nextLong());

    newOrgLabor.setOrganizationId(RandomTestUtil.nextLong());

    newOrgLabor.setTypeId(RandomTestUtil.nextLong());

    newOrgLabor.setSunOpen(RandomTestUtil.nextInt());

    newOrgLabor.setSunClose(RandomTestUtil.nextInt());

    newOrgLabor.setMonOpen(RandomTestUtil.nextInt());

    newOrgLabor.setMonClose(RandomTestUtil.nextInt());

    newOrgLabor.setTueOpen(RandomTestUtil.nextInt());

    newOrgLabor.setTueClose(RandomTestUtil.nextInt());

    newOrgLabor.setWedOpen(RandomTestUtil.nextInt());

    newOrgLabor.setWedClose(RandomTestUtil.nextInt());

    newOrgLabor.setThuOpen(RandomTestUtil.nextInt());

    newOrgLabor.setThuClose(RandomTestUtil.nextInt());

    newOrgLabor.setFriOpen(RandomTestUtil.nextInt());

    newOrgLabor.setFriClose(RandomTestUtil.nextInt());

    newOrgLabor.setSatOpen(RandomTestUtil.nextInt());

    newOrgLabor.setSatClose(RandomTestUtil.nextInt());

    _orgLabors.add(_persistence.update(newOrgLabor));

    OrgLabor existingOrgLabor = _persistence.findByPrimaryKey(newOrgLabor.getPrimaryKey());

    Assert.assertEquals(existingOrgLabor.getMvccVersion(), newOrgLabor.getMvccVersion());
    Assert.assertEquals(existingOrgLabor.getOrgLaborId(), newOrgLabor.getOrgLaborId());
    Assert.assertEquals(existingOrgLabor.getCompanyId(), newOrgLabor.getCompanyId());
    Assert.assertEquals(existingOrgLabor.getOrganizationId(), newOrgLabor.getOrganizationId());
    Assert.assertEquals(existingOrgLabor.getTypeId(), newOrgLabor.getTypeId());
    Assert.assertEquals(existingOrgLabor.getSunOpen(), newOrgLabor.getSunOpen());
    Assert.assertEquals(existingOrgLabor.getSunClose(), newOrgLabor.getSunClose());
    Assert.assertEquals(existingOrgLabor.getMonOpen(), newOrgLabor.getMonOpen());
    Assert.assertEquals(existingOrgLabor.getMonClose(), newOrgLabor.getMonClose());
    Assert.assertEquals(existingOrgLabor.getTueOpen(), newOrgLabor.getTueOpen());
    Assert.assertEquals(existingOrgLabor.getTueClose(), newOrgLabor.getTueClose());
    Assert.assertEquals(existingOrgLabor.getWedOpen(), newOrgLabor.getWedOpen());
    Assert.assertEquals(existingOrgLabor.getWedClose(), newOrgLabor.getWedClose());
    Assert.assertEquals(existingOrgLabor.getThuOpen(), newOrgLabor.getThuOpen());
    Assert.assertEquals(existingOrgLabor.getThuClose(), newOrgLabor.getThuClose());
    Assert.assertEquals(existingOrgLabor.getFriOpen(), newOrgLabor.getFriOpen());
    Assert.assertEquals(existingOrgLabor.getFriClose(), newOrgLabor.getFriClose());
    Assert.assertEquals(existingOrgLabor.getSatOpen(), newOrgLabor.getSatOpen());
    Assert.assertEquals(existingOrgLabor.getSatClose(), newOrgLabor.getSatClose());
  }