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

    VirtualHost newVirtualHost = _persistence.create(pk);

    newVirtualHost.setMvccVersion(ServiceTestUtil.nextLong());

    newVirtualHost.setCompanyId(ServiceTestUtil.nextLong());

    newVirtualHost.setLayoutSetId(ServiceTestUtil.nextLong());

    newVirtualHost.setHostname(ServiceTestUtil.randomString());

    _persistence.update(newVirtualHost);

    VirtualHost existingVirtualHost = _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertEquals(existingVirtualHost.getMvccVersion(), newVirtualHost.getMvccVersion());
    Assert.assertEquals(existingVirtualHost.getVirtualHostId(), newVirtualHost.getVirtualHostId());
    Assert.assertEquals(existingVirtualHost.getCompanyId(), newVirtualHost.getCompanyId());
    Assert.assertEquals(existingVirtualHost.getLayoutSetId(), newVirtualHost.getLayoutSetId());
    Assert.assertEquals(existingVirtualHost.getHostname(), newVirtualHost.getHostname());
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

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

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("virtualHostId", newVirtualHost.getVirtualHostId()));

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

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

    VirtualHost existingVirtualHost = result.get(0);

    Assert.assertEquals(existingVirtualHost, newVirtualHost);
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    VirtualHost newVirtualHost = addVirtualHost();

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

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

    Object newVirtualHostId = newVirtualHost.getVirtualHostId();

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

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

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

    Object existingVirtualHostId = result.get(0);

    Assert.assertEquals(existingVirtualHostId, newVirtualHostId);
  }