HHH-8814 simplified the test a bit
This commit is contained in:
parent
6660bd8d37
commit
61fb660907
|
@ -3,16 +3,16 @@ package org.hibernate.test.id;
|
||||||
|
|
||||||
public class Person {
|
public class Person {
|
||||||
|
|
||||||
private Long id;
|
private long id;
|
||||||
|
|
||||||
public Person() {
|
public Person() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(final Long id) {
|
public void setId(final long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package org.hibernate.test.id;
|
package org.hibernate.test.id;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
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.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -14,27 +17,21 @@ public class SequenceGeneratorTest extends BaseCoreFunctionalTestCase {
|
||||||
return new String[] { "id/Person.hbm.xml" };
|
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
|
@Test
|
||||||
public void testDistinctId() throws Exception {
|
@TestForIssue(jiraKey = "HHH-8814")
|
||||||
|
@RequiresDialectFeature(DialectChecks.SupportsSequences.class)
|
||||||
|
public void testStartOfSequence() throws Exception {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
final int testLength = 8;
|
final Person person = new Person();
|
||||||
final Person[] persons = new Person[testLength];
|
s.persist(person);
|
||||||
for (int i = 0; i < testLength; i++) {
|
|
||||||
persons[i] = new Person();
|
|
||||||
s.persist(persons[i]);
|
|
||||||
}
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
s.close();
|
s.close();
|
||||||
for (int i = 0; i < testLength; i++) {
|
|
||||||
assertEquals(i + 1, persons[i].getId().intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
s = openSession();
|
assertTrue(person.getId() > 0);
|
||||||
tx = s.beginTransaction();
|
|
||||||
s.createQuery("delete from Person").executeUpdate();
|
|
||||||
tx.commit();
|
|
||||||
s.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue