HHH-10693 - Change test to run with PostgreSQL dialect
This commit is contained in:
parent
4ac5978c20
commit
c1023ac49e
|
@ -10,22 +10,30 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.annotations.Nationalized;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.resource.transaction.spi.TransactionStatus;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@TestForIssue(jiraKey = "10495")
|
||||
@RequiresDialect(value = Oracle10gDialect.class)
|
||||
@RequiresDialect(value = {Oracle10gDialect.class, PostgreSQL81Dialect.class})
|
||||
public class StringNationalizedTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +41,26 @@ public class StringNationalizedTest extends BaseCoreFunctionalTestCase {
|
|||
return new Class[] {NationalizedEntity.class};
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
try {
|
||||
final Query query = s.createQuery( "delete from NationalizedEntity" );
|
||||
query.executeUpdate();
|
||||
s.getTransaction().commit();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
if ( s.getTransaction().getStatus() == TransactionStatus.ACTIVE ) {
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveEntityWithNationalizedProperty() {
|
||||
Session s = openSession();
|
||||
|
@ -52,6 +80,17 @@ public class StringNationalizedTest extends BaseCoreFunctionalTestCase {
|
|||
finally {
|
||||
s.close();
|
||||
}
|
||||
|
||||
s = openSession();
|
||||
try {
|
||||
final Query query = s.createQuery( "from NationalizedEntity where name = :name" );
|
||||
query.setString( "name", "Hello" );
|
||||
final List list = query.list();
|
||||
assertThat( list.size(), is( 1 ) );
|
||||
}
|
||||
finally {
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Entity(name = "NationalizedEntity")
|
||||
|
|
Loading…
Reference in New Issue