From fd21be8705ed3c41193cc59ccc2a0816479b6272 Mon Sep 17 00:00:00 2001 From: Koen Aers Date: Mon, 11 Jan 2016 10:48:31 +0100 Subject: [PATCH] HHH-10430: Comment for class is ignored when using subselect in hibernate mapping - Test demonstrating the issue --- .../test/hbm/comment/ClassCommentTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/hbm/comment/ClassCommentTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/hbm/comment/ClassCommentTest.java b/hibernate-core/src/test/java/org/hibernate/test/hbm/comment/ClassCommentTest.java new file mode 100644 index 0000000000..ff8f01fdb7 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/hbm/comment/ClassCommentTest.java @@ -0,0 +1,41 @@ +package org.hibernate.test.hbm.comment; + +import java.io.StringReader; + +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.engine.jdbc.ReaderInputStream; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Table; +import org.junit.Assert; +import org.junit.Test; + +public class ClassCommentTest { + + private static String CLASS_COMMENT_HBM_XML = + " "+ + " "+ + " This is class 'Foo' with property 'bar'. "+ + " "+ + " "+ + " "+ + " "+ + " "+ + " "; + + @Test + public void testClassComment() { + StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder() + .applySetting("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); + MetadataSources metadataSources = new MetadataSources(serviceRegistryBuilder.build()); + metadataSources.addInputStream(new ReaderInputStream(new StringReader(CLASS_COMMENT_HBM_XML))); + Metadata metadata = metadataSources.buildMetadata(); + PersistentClass pc = metadata.getEntityBinding("org.hibernate.test.hbm.Foo"); + Assert.assertNotNull(pc); + Table table = pc.getTable(); + Assert.assertNotNull(table); + Assert.assertEquals("This is class 'Foo' with property 'bar'.", table.getComment()); + } + +}