@Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    DDLRecordVersion newDDLRecordVersion = addDDLRecordVersion();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(DDLRecordVersion.class, _dynamicQueryClassLoader);

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("recordVersionId", newDDLRecordVersion.getRecordVersionId()));

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

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

    DDLRecordVersion existingDDLRecordVersion = result.get(0);

    Assert.assertEquals(existingDDLRecordVersion, newDDLRecordVersion);
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    DDLRecordVersion newDDLRecordVersion = addDDLRecordVersion();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(DDLRecordVersion.class, _dynamicQueryClassLoader);

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

    Object newRecordVersionId = newDDLRecordVersion.getRecordVersionId();

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

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

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

    Object existingRecordVersionId = result.get(0);

    Assert.assertEquals(existingRecordVersionId, newRecordVersionId);
  }
 @Override
 public Long get(DDLRecordVersion ddlRecordVersion) {
   return ddlRecordVersion.getRecordVersionId();
 }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    DDLRecordVersion newDDLRecordVersion = _persistence.create(pk);

    newDDLRecordVersion.setGroupId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setCompanyId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setUserId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setUserName(RandomTestUtil.randomString());

    newDDLRecordVersion.setCreateDate(RandomTestUtil.nextDate());

    newDDLRecordVersion.setDDMStorageId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setRecordSetId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setRecordId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setVersion(RandomTestUtil.randomString());

    newDDLRecordVersion.setDisplayIndex(RandomTestUtil.nextInt());

    newDDLRecordVersion.setStatus(RandomTestUtil.nextInt());

    newDDLRecordVersion.setStatusByUserId(RandomTestUtil.nextLong());

    newDDLRecordVersion.setStatusByUserName(RandomTestUtil.randomString());

    newDDLRecordVersion.setStatusDate(RandomTestUtil.nextDate());

    _ddlRecordVersions.add(_persistence.update(newDDLRecordVersion));

    DDLRecordVersion existingDDLRecordVersion =
        _persistence.findByPrimaryKey(newDDLRecordVersion.getPrimaryKey());

    Assert.assertEquals(
        existingDDLRecordVersion.getRecordVersionId(), newDDLRecordVersion.getRecordVersionId());
    Assert.assertEquals(existingDDLRecordVersion.getGroupId(), newDDLRecordVersion.getGroupId());
    Assert.assertEquals(
        existingDDLRecordVersion.getCompanyId(), newDDLRecordVersion.getCompanyId());
    Assert.assertEquals(existingDDLRecordVersion.getUserId(), newDDLRecordVersion.getUserId());
    Assert.assertEquals(existingDDLRecordVersion.getUserName(), newDDLRecordVersion.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDDLRecordVersion.getCreateDate()),
        Time.getShortTimestamp(newDDLRecordVersion.getCreateDate()));
    Assert.assertEquals(
        existingDDLRecordVersion.getDDMStorageId(), newDDLRecordVersion.getDDMStorageId());
    Assert.assertEquals(
        existingDDLRecordVersion.getRecordSetId(), newDDLRecordVersion.getRecordSetId());
    Assert.assertEquals(existingDDLRecordVersion.getRecordId(), newDDLRecordVersion.getRecordId());
    Assert.assertEquals(existingDDLRecordVersion.getVersion(), newDDLRecordVersion.getVersion());
    Assert.assertEquals(
        existingDDLRecordVersion.getDisplayIndex(), newDDLRecordVersion.getDisplayIndex());
    Assert.assertEquals(existingDDLRecordVersion.getStatus(), newDDLRecordVersion.getStatus());
    Assert.assertEquals(
        existingDDLRecordVersion.getStatusByUserId(), newDDLRecordVersion.getStatusByUserId());
    Assert.assertEquals(
        existingDDLRecordVersion.getStatusByUserName(), newDDLRecordVersion.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingDDLRecordVersion.getStatusDate()),
        Time.getShortTimestamp(newDDLRecordVersion.getStatusDate()));
  }