@Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    DLFileEntryMetadata newDLFileEntryMetadata = _persistence.create(pk);

    newDLFileEntryMetadata.setUuid(ServiceTestUtil.randomString());

    newDLFileEntryMetadata.setDDMStorageId(ServiceTestUtil.nextLong());

    newDLFileEntryMetadata.setDDMStructureId(ServiceTestUtil.nextLong());

    newDLFileEntryMetadata.setFileEntryTypeId(ServiceTestUtil.nextLong());

    newDLFileEntryMetadata.setFileEntryId(ServiceTestUtil.nextLong());

    newDLFileEntryMetadata.setFileVersionId(ServiceTestUtil.nextLong());

    _persistence.update(newDLFileEntryMetadata, false);

    DLFileEntryMetadata existingDLFileEntryMetadata =
        _persistence.findByPrimaryKey(newDLFileEntryMetadata.getPrimaryKey());

    Assert.assertEquals(existingDLFileEntryMetadata.getUuid(), newDLFileEntryMetadata.getUuid());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getFileEntryMetadataId(),
        newDLFileEntryMetadata.getFileEntryMetadataId());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getDDMStorageId(), newDLFileEntryMetadata.getDDMStorageId());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getDDMStructureId(),
        newDLFileEntryMetadata.getDDMStructureId());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getFileEntryTypeId(),
        newDLFileEntryMetadata.getFileEntryTypeId());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getFileEntryId(), newDLFileEntryMetadata.getFileEntryId());
    Assert.assertEquals(
        existingDLFileEntryMetadata.getFileVersionId(), newDLFileEntryMetadata.getFileVersionId());
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    DLFileEntryMetadata newDLFileEntryMetadata = addDLFileEntryMetadata();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            DLFileEntryMetadata.class, DLFileEntryMetadata.class.getClassLoader());

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq(
            "fileEntryMetadataId", newDLFileEntryMetadata.getFileEntryMetadataId()));

    List<DLFileEntryMetadata> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    DLFileEntryMetadata existingDLFileEntryMetadata = result.get(0);

    Assert.assertEquals(existingDLFileEntryMetadata, newDLFileEntryMetadata);
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    DLFileEntryMetadata newDLFileEntryMetadata = addDLFileEntryMetadata();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            DLFileEntryMetadata.class, DLFileEntryMetadata.class.getClassLoader());

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("fileEntryMetadataId"));

    Object newFileEntryMetadataId = newDLFileEntryMetadata.getFileEntryMetadataId();

    dynamicQuery.add(
        RestrictionsFactoryUtil.in("fileEntryMetadataId", new Object[] {newFileEntryMetadataId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingFileEntryMetadataId = result.get(0);

    Assert.assertEquals(existingFileEntryMetadataId, newFileEntryMetadataId);
  }