From b5586bc94156b6e07019a1f374c5ccb97102d19a Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Thu, 4 Feb 2016 14:13:49 +0000 Subject: [PATCH] HHH-10495 - Add test for issue --- .../nationalized/StringNationalizedTest.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java b/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java new file mode 100644 index 0000000000..c8f48b1ea8 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/nationalized/StringNationalizedTest.java @@ -0,0 +1,68 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.test.nationalized; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.Session; +import org.hibernate.annotations.Nationalized; +import org.hibernate.dialect.Oracle10gDialect; +import org.hibernate.resource.transaction.spi.TransactionStatus; + +import org.junit.Test; + +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +/** + * @author Andrea Boriero + */ +@TestForIssue(jiraKey = "10495") +@RequiresDialect(value = Oracle10gDialect.class) +public class StringNationalizedTest extends BaseCoreFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] {NationalizedEntity.class}; + } + + @Test + public void testSaveEntityWithNationalizedProperty() { + Session s = openSession(); + s.getTransaction().begin(); + try { + NationalizedEntity ne = new NationalizedEntity(); + ne.name = "Hello"; + s.save( ne ); + s.getTransaction().commit(); + } + catch (Exception e) { + if ( s.getTransaction().getStatus() == TransactionStatus.ACTIVE ) { + s.getTransaction().rollback(); + } + throw e; + } + finally { + s.close(); + } + } + + @Entity(name = "NationalizedEntity") + @Table(name = "NATIONALIZED_ENTITY") + public static class NationalizedEntity { + @Id + @GeneratedValue + private long id; + + @Nationalized + String name; + } +}