public void testUpdateExisting() throws Exception {
    long pk = nextLong();

    UserTracker newUserTracker = _persistence.create(pk);

    newUserTracker.setCompanyId(nextLong());
    newUserTracker.setUserId(nextLong());
    newUserTracker.setModifiedDate(nextDate());
    newUserTracker.setSessionId(randomString());
    newUserTracker.setRemoteAddr(randomString());
    newUserTracker.setRemoteHost(randomString());
    newUserTracker.setUserAgent(randomString());

    _persistence.update(newUserTracker, false);

    UserTracker existingUserTracker = _persistence.findByPrimaryKey(newUserTracker.getPrimaryKey());

    assertEquals(existingUserTracker.getUserTrackerId(), newUserTracker.getUserTrackerId());
    assertEquals(existingUserTracker.getCompanyId(), newUserTracker.getCompanyId());
    assertEquals(existingUserTracker.getUserId(), newUserTracker.getUserId());
    assertEquals(
        Time.getShortTimestamp(existingUserTracker.getModifiedDate()),
        Time.getShortTimestamp(newUserTracker.getModifiedDate()));
    assertEquals(existingUserTracker.getSessionId(), newUserTracker.getSessionId());
    assertEquals(existingUserTracker.getRemoteAddr(), newUserTracker.getRemoteAddr());
    assertEquals(existingUserTracker.getRemoteHost(), newUserTracker.getRemoteHost());
    assertEquals(existingUserTracker.getUserAgent(), newUserTracker.getUserAgent());
  }
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    UserTracker newUserTracker = addUserTracker();

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

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("userTrackerId", newUserTracker.getUserTrackerId()));

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

    assertEquals(1, result.size());

    UserTracker existingUserTracker = result.get(0);

    assertEquals(existingUserTracker, newUserTracker);
  }