@Test
  public void testIncrementTimestampVersion() {
    Session s = openSession();
    Transaction t = s.beginTransaction();

    TimestampVersioned entity = new TimestampVersioned("ts-vers");
    s.save(entity);
    t.commit();
    s.close();

    Date initialVersion = entity.getVersion();

    synchronized (this) {
      try {
        wait(1500);
      } catch (InterruptedException ie) {
      }
    }

    s = openSession();
    t = s.beginTransaction();
    int count =
        s.createQuery("update versioned TimestampVersioned set name = name").executeUpdate();
    assertEquals("incorrect exec count", 1, count);
    t.commit();

    t = s.beginTransaction();
    entity = (TimestampVersioned) s.load(TimestampVersioned.class, entity.getId());
    assertTrue("version not incremented", entity.getVersion().after(initialVersion));

    s.delete(entity);
    t.commit();
    s.close();
  }
  @Test
  @SuppressWarnings({"UnnecessaryUnboxing"})
  @RequiresDialectFeature(
      value = DialectChecks.SupportsParametersInInsertSelectCheck.class,
      comment = "dialect does not support parameter in INSERT ... SELECT")
  public void testInsertWithGeneratedTimestampVersion() {
    // Make sure the env supports bulk inserts with generated ids...
    if (!supportsBulkInsertIdGeneration(TimestampVersioned.class)) {
      SkipLog.reportSkip(
          "bulk id generation not supported",
          "test bulk inserts with generated id and generated timestamp");
      return;
    }

    Session s = openSession();
    Transaction t = s.beginTransaction();

    TimestampVersioned entity = new TimestampVersioned("int-vers");
    s.save(entity);
    s.createQuery("select id, name, version from TimestampVersioned").list();
    t.commit();
    s.close();

    Long initialId = entity.getId();
    // Date initialVersion = entity.getVersion();

    s = openSession();
    t = s.beginTransaction();
    int count =
        s.createQuery("insert into TimestampVersioned ( name ) select name from TimestampVersioned")
            .executeUpdate();
    t.commit();
    s.close();

    assertEquals("unexpected insertion count", 1, count);

    s = openSession();
    t = s.beginTransaction();
    TimestampVersioned created =
        (TimestampVersioned)
            s.createQuery("from TimestampVersioned where id <> :initialId")
                .setLong("initialId", initialId.longValue())
                .uniqueResult();
    t.commit();
    s.close();

    assertNotNull(created.getVersion());
    // assertEquals( "version was not seeded", initialVersion, created.getVersion() );

    s = openSession();
    t = s.beginTransaction();
    s.createQuery("delete TimestampVersioned").executeUpdate();
    t.commit();
    s.close();
  }