From 73e0c3dad23b3e3d5998fb95f9e3009fc5f83986 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 10 Apr 2009 22:37:51 +0000 Subject: [PATCH] JBPAPP-1124 ANN-779 : Oracle/DB2 - Identifier is too long git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@16298 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../test/annotations/generics/Classes.java | 47 ++++++++++++++++ .../generics/EmbeddedGenericsTest.java | 55 ++++--------------- 2 files changed, 57 insertions(+), 45 deletions(-) create mode 100644 annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java diff --git a/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java b/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java new file mode 100644 index 0000000000..099540a4f1 --- /dev/null +++ b/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java @@ -0,0 +1,47 @@ +package org.hibernate.test.annotations.generics; + +/** + * A test case for ANN-494. + * + * @author Edward Costello + * @author Paolo Perrotta + */ +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.hibernate.annotations.CollectionOfElements; + +public class Classes { + + @Embeddable + public static class Edition { + T name; + } + + @Entity + public static class Book { + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + Long id; + + @Embedded + Edition edition; + } + + @Entity + public static class PopularBook { + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + Long id; + + @CollectionOfElements + Set> editions = new HashSet>(); + } +} diff --git a/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java b/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java index 7ab86e880b..246a26b84f 100644 --- a/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java +++ b/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java @@ -6,62 +6,51 @@ package org.hibernate.test.annotations.generics; * @author Edward Costello * @author Paolo Perrotta */ -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.annotations.CollectionOfElements; import org.hibernate.test.annotations.TestCase; public class EmbeddedGenericsTest extends TestCase { Session session; - Edition edition; + Classes.Edition edition; public void setUp() throws Exception { super.setUp(); session = openSession(); session.getTransaction().begin(); - edition = new Edition(); + edition = new Classes.Edition(); edition.name = "Second"; } public void testWorksWithGenericEmbedded() { - Book b = new Book(); + Classes.Book b = new Classes.Book(); b.edition = edition; persist( b ); - Book retrieved = (Book)find( Book.class, b.id ); + Classes.Book retrieved = (Classes.Book)find( Classes.Book.class, b.id ); assertEquals( "Second", retrieved.edition.name ); - clean( Book.class, b.id ); + clean( Classes.Book.class, b.id ); session.close(); } public void testWorksWithGenericCollectionOfElements() { - PopularBook b = new PopularBook(); + Classes.PopularBook b = new Classes.PopularBook(); b.editions.add( edition ); persist( b ); - PopularBook retrieved = (PopularBook)find( PopularBook.class, b.id ); + Classes.PopularBook retrieved = (Classes.PopularBook)find( Classes.PopularBook.class, b.id ); assertEquals( "Second", retrieved.editions.iterator().next().name ); - clean( PopularBook.class, b.id ); + clean( Classes.PopularBook.class, b.id ); session.close(); } protected Class[] getMappings() { return new Class[]{ - Book.class, - PopularBook.class + Classes.Book.class, + Classes.PopularBook.class }; } @@ -81,28 +70,4 @@ public class EmbeddedGenericsTest extends TestCase { tx.commit(); } - @Embeddable - public static class Edition { - T name; - } - - @Entity - public static class Book { - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - Long id; - - @Embedded - Edition edition; - } - - @Entity - public static class PopularBook { - @Id - @GeneratedValue(strategy=GenerationType.AUTO) - Long id; - - @CollectionOfElements - Set> editions = new HashSet>(); - } }