From 22548f11271e87b647dfbe3412e9c5b95846d334 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Mon, 9 Jan 2017 17:13:36 +0200 Subject: [PATCH] HHH-10183 - Mapping for NVARCHAR in SqlServer not working with native queries; org.hibernate.MappingException: No Dialect mapping for JDBC type: -9 Restrict test case for SQL Server only --- .../scalar/NationalizedScalarQueryTest.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/scalar/NationalizedScalarQueryTest.java b/hibernate-core/src/test/java/org/hibernate/test/scalar/NationalizedScalarQueryTest.java index 45b4e5d2ab..32a07b63e1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/scalar/NationalizedScalarQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/scalar/NationalizedScalarQueryTest.java @@ -13,11 +13,10 @@ import javax.persistence.Id; import javax.persistence.Table; import org.hibernate.annotations.Nationalized; -import org.hibernate.dialect.DB2Dialect; -import org.hibernate.dialect.PostgreSQL81Dialect; +import org.hibernate.dialect.SQLServer2008Dialect; import org.hibernate.testing.FailureExpected; -import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -28,66 +27,68 @@ import static org.junit.Assert.assertEquals; /** * @author Vlad Mihalcea */ -@TestForIssue( jiraKey = "HHH-10183" ) -@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString") -@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL jdbc driver doesn't support setNString") +@TestForIssue(jiraKey = "HHH-10183") +@RequiresDialect(SQLServer2008Dialect.class) public class NationalizedScalarQueryTest extends BaseCoreFunctionalTestCase { - + @Override protected Class[] getAnnotatedClasses() { return new Class[] { User.class }; } @Test - @FailureExpected( jiraKey = "HHH-10183" ) + @FailureExpected(jiraKey = "HHH-10183") public void testScalarResult() { - User user1 = new User(1, "Chris"); - User user2 = new User(2, "Steve"); + User user1 = new User( 1, "Chris" ); + User user2 = new User( 2, "Steve" ); doInHibernate( this::sessionFactory, session -> { - session.save(user1); - session.save(user2); + session.save( user1 ); + session.save( user2 ); } ); doInHibernate( this::sessionFactory, session -> { - List users = session.createNativeQuery( "select * from users").getResultList(); + List users = session.createNativeQuery( + "select * from users" ).getResultList(); assertEquals( 2, users.size() ); } ); } - + @Entity(name = "User") @Table(name = "users") public static class User { - + private Integer id; private String name; - + public User() { - + } - + public User(Integer id, String name) { this.id = id; this.name = name; } - + @Id public Integer getId() { return id; } + public void setId(Integer id) { this.id = id; } - + @Nationalized @Column(nullable = false) public String getName() { return name; } + public void setName(String name) { this.name = name; } - + } } \ No newline at end of file