Author: gbadner
Date: 2009-04-10 18:37:51 -0400 (Fri, 10 Apr 2009)
New Revision: 16298
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java
Log:
JBPAPP-1124 ANN-779 : Oracle/DB2 - Identifier is too long
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java
(rev 0)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/Classes.java 2009-04-10
22:37:51 UTC (rev 16298)
@@ -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> {
+ T name;
+ }
+
+ @Entity
+ public static class Book {
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ Long id;
+
+ @Embedded
+ Edition<String> edition;
+ }
+
+ @Entity
+ public static class PopularBook {
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ Long id;
+
+ @CollectionOfElements
+ Set<Edition<String>> editions = new
HashSet<Edition<String>>();
+ }
+}
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java 2009-04-10
22:14:12 UTC (rev 16297)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/generics/EmbeddedGenericsTest.java 2009-04-10
22:37:51 UTC (rev 16298)
@@ -6,62 +6,51 @@
* @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<String> edition;
+ Classes.Edition<String> edition;
public void setUp() throws Exception {
super.setUp();
session = openSession();
session.getTransaction().begin();
- edition = new Edition<String>();
+ edition = new Classes.Edition<String>();
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 @@
tx.commit();
}
- @Embeddable
- public static class Edition<T> {
- T name;
- }
-
- @Entity
- public static class Book {
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- Long id;
-
- @Embedded
- Edition<String> edition;
- }
-
- @Entity
- public static class PopularBook {
- @Id
- @GeneratedValue(strategy=GenerationType.AUTO)
- Long id;
-
- @CollectionOfElements
- Set<Edition<String>> editions = new
HashSet<Edition<String>>();
- }
}