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

    JournalArticleImage newJournalArticleImage = _persistence.create(pk);

    newJournalArticleImage.setGroupId(RandomTestUtil.nextLong());

    newJournalArticleImage.setArticleId(RandomTestUtil.randomString());

    newJournalArticleImage.setVersion(RandomTestUtil.nextDouble());

    newJournalArticleImage.setElInstanceId(RandomTestUtil.randomString());

    newJournalArticleImage.setElName(RandomTestUtil.randomString());

    newJournalArticleImage.setLanguageId(RandomTestUtil.randomString());

    newJournalArticleImage.setTempImage(RandomTestUtil.randomBoolean());

    _journalArticleImages.add(_persistence.update(newJournalArticleImage));

    JournalArticleImage existingJournalArticleImage =
        _persistence.findByPrimaryKey(newJournalArticleImage.getPrimaryKey());

    Assert.assertEquals(
        existingJournalArticleImage.getArticleImageId(),
        newJournalArticleImage.getArticleImageId());
    Assert.assertEquals(
        existingJournalArticleImage.getGroupId(), newJournalArticleImage.getGroupId());
    Assert.assertEquals(
        existingJournalArticleImage.getArticleId(), newJournalArticleImage.getArticleId());
    AssertUtils.assertEquals(
        existingJournalArticleImage.getVersion(), newJournalArticleImage.getVersion());
    Assert.assertEquals(
        existingJournalArticleImage.getElInstanceId(), newJournalArticleImage.getElInstanceId());
    Assert.assertEquals(
        existingJournalArticleImage.getElName(), newJournalArticleImage.getElName());
    Assert.assertEquals(
        existingJournalArticleImage.getLanguageId(), newJournalArticleImage.getLanguageId());
    Assert.assertEquals(
        existingJournalArticleImage.getTempImage(), newJournalArticleImage.getTempImage());
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    JournalArticleImage newJournalArticleImage = addJournalArticleImage();

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

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("articleImageId", newJournalArticleImage.getArticleImageId()));

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

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

    JournalArticleImage existingJournalArticleImage = result.get(0);

    Assert.assertEquals(existingJournalArticleImage, newJournalArticleImage);
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    JournalArticleImage newJournalArticleImage = addJournalArticleImage();

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

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

    Object newArticleImageId = newJournalArticleImage.getArticleImageId();

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

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

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

    Object existingArticleImageId = result.get(0);

    Assert.assertEquals(existingArticleImageId, newArticleImageId);
  }