Author: smarlow(a)redhat.com
Date: 2010-01-05 13:50:48 -0500 (Tue, 05 Jan 2010)
New Revision: 18416
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java
Log:
HHH-4684 Make sure @Lob works with @ElementCollection
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2010-01-05
18:00:34 UTC (rev 18415)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java 2010-01-05
18:50:48 UTC (rev 18416)
@@ -27,6 +27,9 @@
import java.math.BigDecimal;
import java.util.Currency;
import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import org.hibernate.AnnotationException;
import org.hibernate.Hibernate;
@@ -469,6 +472,17 @@
Country country = new Country();
country.setName( "Middle Earth" );
forest.setCountry( country );
+ Set<Country> near = new HashSet<Country>();
+ country = new Country();
+ country.setName("Mordor");
+ near.add(country);
+ country = new Country();
+ country.setName("Gondor");
+ near.add(country);
+ country = new Country();
+ country.setName("Eriador");
+ near.add(country);
+ forest.setNear(near);
Session s;
Transaction tx;
s = openSession();
@@ -481,8 +495,17 @@
tx = s.beginTransaction();
forest = (Forest) s.get( Forest.class, forest.getId() );
assertNotNull( forest );
- assertNotNull( forest.getCountry() );
+ country = forest.getCountry();
+ assertNotNull( country );
assertEquals( country.getName(), forest.getCountry().getName() );
+ near = forest.getNear();
+ assertTrue("correct number of nearby countries", near.size() == 3);
+ for (Iterator iter = near.iterator(); iter.hasNext();) {
+ country = (Country)iter.next();
+ String name = country.getName();
+ assertTrue("found expected nearby country " + name,
+ (name.equals("Mordor") || name.equals("Gondor") ||
name.equals("Eriador")));
+ }
tx.commit();
s.close();
}
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java
===================================================================
---
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java 2010-01-05
18:00:34 UTC (rev 18415)
+++
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/entity/Forest.java 2010-01-05
18:50:48 UTC (rev 18416)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.test.annotations.entity;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@@ -19,6 +20,8 @@
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
+import java.util.Set;
+
/**
* Use hibernate specific annotations
*
@@ -47,6 +50,7 @@
private String smallText;
private String bigText;
private Country country;
+ private Set near;
@OptimisticLock(excluded=true)
@Type(type = "text")
@@ -110,4 +114,15 @@
public void setCountry(Country country) {
this.country = country;
}
+
+ @Lob
+ @ElementCollection
+ public Set<Country> getNear() {
+ return near;
+ }
+
+ public void setNear(Set<Country>near) {
+ this.near = near;
+ }
+
}
Show replies by thread