Author: epbernard
Date: 2006-11-30 16:54:27 -0500 (Thu, 30 Nov 2006)
New Revision: 10902
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Generation.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationGroup.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationUser.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/MapKeyTest.java
Log:
HHH-2275 + ANN-450 tests
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Generation.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Generation.java 2006-11-30
21:50:48 UTC (rev 10901)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/Generation.java 2006-11-30
21:54:27 UTC (rev 10902)
@@ -0,0 +1,27 @@
+//$Id: $
+package org.hibernate.test.annotations.indexcoll;
+
+import javax.persistence.Embeddable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Embeddable
+public class Generation {
+
+ private String age;
+ private String culture;
+
+ public String getAge() {
+ return age;
+ }
+ public void setAge(String age) {
+ this.age = age;
+ }
+ public String getCulture() {
+ return culture;
+ }
+ public void setCulture(String culture) {
+ this.culture = culture;
+ }
+}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationGroup.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationGroup.java 2006-11-30
21:50:48 UTC (rev 10901)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationGroup.java 2006-11-30
21:54:27 UTC (rev 10902)
@@ -0,0 +1,37 @@
+//$Id: $
+package org.hibernate.test.annotations.indexcoll;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class GenerationGroup {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private Generation generation;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Generation getGeneration() {
+ return generation;
+ }
+
+ public void setGeneration(Generation generation) {
+ this.generation = generation;
+ }
+
+
+}
\ No newline at end of file
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationUser.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationUser.java 2006-11-30
21:50:48 UTC (rev 10901)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/GenerationUser.java 2006-11-30
21:54:27 UTC (rev 10902)
@@ -0,0 +1,43 @@
+//$Id: $
+package org.hibernate.test.annotations.indexcoll;
+
+import java.util.Map;
+import java.util.HashMap;
+import javax.persistence.OneToMany;
+import javax.persistence.Id;
+import javax.persistence.Entity;
+import javax.persistence.MapKey;
+import javax.persistence.GeneratedValue;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class GenerationUser {
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany
+ @MapKey(name="generation")
+ private Map<Generation, GenerationGroup> ref = new HashMap<Generation,
GenerationGroup>();
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Map<Generation, GenerationGroup> getRef() {
+ return ref;
+ }
+
+ public void setRef(Map<Generation, GenerationGroup> ref) {
+ this.ref = ref;
+ }
+
+
+}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/MapKeyTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/MapKeyTest.java 2006-11-30
21:50:48 UTC (rev 10901)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/indexcoll/MapKeyTest.java 2006-11-30
21:54:27 UTC (rev 10902)
@@ -0,0 +1,40 @@
+//$Id: $
+package org.hibernate.test.annotations.indexcoll;
+
+import org.hibernate.test.annotations.TestCase;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class MapKeyTest extends TestCase {
+
+ public void testMapKeyOnEmbeddedId() {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Generation c = new Generation();
+ c.setAge( "a" );
+ c.setCulture( "b" );
+ GenerationGroup r = new GenerationGroup();
+ r.setGeneration( c );
+ s.persist( r );
+ GenerationUser m = new GenerationUser();
+ s.persist( m );
+ m.getRef().put( c, r );
+ s.flush();
+ s.clear();
+
+ m = (GenerationUser) s.get( GenerationUser.class, m.getId() );
+ assertEquals( "a", m.getRef().keySet().iterator().next().getAge() );
+ tx.rollback();
+ s.close();
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ GenerationUser.class,
+ GenerationGroup.class
+ };
+ }
+}
Show replies by date