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
This commit is contained in:
Vlad Mihalcea 2017-01-09 17:13:36 +02:00
parent 8f5bc492e8
commit 22548f1127
1 changed files with 22 additions and 21 deletions

View File

@ -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<Object[]> users = session.createNativeQuery( "select * from users").getResultList();
List<Object[]> 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;
}
}
}