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

    ServiceComponent newServiceComponent = _persistence.create(pk);

    newServiceComponent.setMvccVersion(RandomTestUtil.nextLong());

    newServiceComponent.setBuildNamespace(RandomTestUtil.randomString());

    newServiceComponent.setBuildNumber(RandomTestUtil.nextLong());

    newServiceComponent.setBuildDate(RandomTestUtil.nextLong());

    newServiceComponent.setData(RandomTestUtil.randomString());

    _serviceComponents.add(_persistence.update(newServiceComponent));

    ServiceComponent existingServiceComponent =
        _persistence.findByPrimaryKey(newServiceComponent.getPrimaryKey());

    Assert.assertEquals(
        existingServiceComponent.getMvccVersion(), newServiceComponent.getMvccVersion());
    Assert.assertEquals(
        existingServiceComponent.getServiceComponentId(),
        newServiceComponent.getServiceComponentId());
    Assert.assertEquals(
        existingServiceComponent.getBuildNamespace(), newServiceComponent.getBuildNamespace());
    Assert.assertEquals(
        existingServiceComponent.getBuildNumber(), newServiceComponent.getBuildNumber());
    Assert.assertEquals(
        existingServiceComponent.getBuildDate(), newServiceComponent.getBuildDate());
    Assert.assertEquals(existingServiceComponent.getData(), newServiceComponent.getData());
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    ServiceComponent newServiceComponent = addServiceComponent();

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

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq(
            "serviceComponentId", newServiceComponent.getServiceComponentId()));

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

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

    ServiceComponent existingServiceComponent = result.get(0);

    Assert.assertEquals(existingServiceComponent, newServiceComponent);
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    ServiceComponent newServiceComponent = addServiceComponent();

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

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

    Object newServiceComponentId = newServiceComponent.getServiceComponentId();

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

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

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

    Object existingServiceComponentId = result.get(0);

    Assert.assertEquals(existingServiceComponentId, newServiceComponentId);
  }