[hibernate-commits] Hibernate SVN: r10913 - branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Mon Dec 4 15:32:24 EST 2006
Author: epbernard
Date: 2006-12-04 15:32:20 -0500 (Mon, 04 Dec 2006)
New Revision: 10913
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
Log:
more tests
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2006-12-04 17:10:27 UTC (rev 10912)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/AddressBook.java 2006-12-04 20:32:20 UTC (rev 10913)
@@ -9,6 +9,7 @@
import javax.persistence.Id;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.JoinTable;
/**
* @author Emmanuel Bernard
@@ -61,6 +62,7 @@
@MapKey(name = "directory")
@OneToMany(mappedBy = "book")
+ @JoinTable(name="Dir_Entry")
public Map<AlphabeticalDirectory, AddressEntry> getDirectoryEntries() {
return directoryEntries;
}
Modified: branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java
===================================================================
--- branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-12-04 17:10:27 UTC (rev 10912)
+++ branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/IndexedCollectionTest.java 2006-12-04 20:32:20 UTC (rev 10913)
@@ -395,6 +395,32 @@
s.close();
}
+ public void testMapKeyEntityEntity() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ AddressBook book = new AddressBook();
+ s.persist( book );
+ AddressEntry entry = new AddressEntry();
+ entry.setCity( "Atlanta");
+ AddressEntryPk pk = new AddressEntryPk("Coca", "Cola" );
+ entry.setPerson( pk );
+ entry.setBook( book );
+ AlphabeticalDirectory ad = new AlphabeticalDirectory();
+ ad.setName( "C");
+ s.persist( ad );
+ entry.setDirectory( ad );
+ s.persist( entry );
+ book.getDirectoryEntries().put( ad, entry );
+ s.flush();
+ s.clear();
+
+ book = (AddressBook) s.get( AddressBook.class, book.getId() );
+ assertEquals( 1, book.getDirectoryEntries().size() );
+ assertEquals( "C", book.getDirectoryEntries().keySet().iterator().next().getName() );
+ tx.rollback();
+ s.close();
+ }
+
public void testEntityKeyElementTarget() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
More information about the hibernate-commits
mailing list