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()); + } + +}