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
This commit is contained in:
parent
7d36b9dfd3
commit
73e0c3dad2
|
@ -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>>();
|
||||
}
|
||||
}
|
|
@ -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<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 @@ public class EmbeddedGenericsTest extends TestCase {
|
|||
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>>();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue