Skip to content

Commit

Permalink
HHH-8814 simplified the test a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Feb 12, 2014
1 parent 6660bd8 commit 61fb660
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

public class Person {

private Long id;
private long id;

public Person() {
}

public Long getId() {
public long getId() {
return id;
}

public void setId(final Long id) {
public void setId(final long id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.hibernate.test.id;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;

Expand All @@ -14,27 +17,21 @@ public String[] getMappings() {
return new String[] { "id/Person.hbm.xml" };
}

/**
* This seems a little trivial, but we need to guarantee that all Dialects start their sequences on a non-0 value.
*/
@Test
public void testDistinctId() throws Exception {
@TestForIssue(jiraKey = "HHH-8814")
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
public void testStartOfSequence() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
final int testLength = 8;
final Person[] persons = new Person[testLength];
for (int i = 0; i < testLength; i++) {
persons[i] = new Person();
s.persist(persons[i]);
}
tx.commit();
s.close();
for (int i = 0; i < testLength; i++) {
assertEquals(i + 1, persons[i].getId().intValue());
}

s = openSession();
tx = s.beginTransaction();
s.createQuery("delete from Person").executeUpdate();
final Person person = new Person();
s.persist(person);
tx.commit();
s.close();

assertTrue(person.getId() > 0);
}

}

0 comments on commit 61fb660

Please sign in to comment.