Author: hardy.ferentschik
Date: 2008-06-09 11:57:07 -0400 (Mon, 09 Jun 2008)
New Revision: 14754
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java
Log:
ANN-723
- Modified the Matrix class to use a SortedMap in order to test the issue (actual fix in
commons-annotations)
- Minor code clean ups
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2008-06-09
15:50:47 UTC (rev 14753)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CollectionElementTest.java 2008-06-09
15:57:07 UTC (rev 14754)
@@ -1,7 +1,6 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -14,9 +13,11 @@
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
+@SuppressWarnings("unchecked")
public class CollectionElementTest extends TestCase {
-
+
public void testSimpleElement() throws Exception {
assertEquals(
"BoyFavoriteNumbers",
@@ -180,7 +181,6 @@
assertEquals( 1, l.size() );
TestCourse t = (TestCourse) s.get( TestCourse.class, test.getTestCourseId() );
- Iterator it = t.getTitle().getVariations().values().iterator();
assertEquals( 1, t.getTitle().getVariations().size() );
tx.rollback();
@@ -202,7 +202,6 @@
s.close();
}
-
protected Class[] getMappings() {
return new Class[] {
Boy.class,
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java 2008-06-09
15:50:47 UTC (rev 14753)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/CountryAttitude.java 2008-06-09
15:57:07 UTC (rev 14754)
@@ -17,7 +17,7 @@
private boolean likes;
// TODO: This currently does not work
- //@ManyToOne(optional = false)
+// @ManyToOne(optional = false)
// public Boy getBoy() {
// return boy;
// }
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java 2008-06-09
15:50:47 UTC (rev 14753)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/Matrix.java 2008-06-09
15:57:07 UTC (rev 14754)
@@ -2,13 +2,17 @@
package org.hibernate.test.annotations.collectionelement;
import java.util.Map;
-import java.util.HashMap;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
+import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.MapKey;
-import org.hibernate.annotations.CollectionOfElements;
+import org.hibernate.annotations.Sort;
+import org.hibernate.annotations.SortType;
import org.hibernate.annotations.Type;
/**
@@ -19,10 +23,12 @@
@Id
@GeneratedValue
private Integer id;
+
@MapKey(type = @Type(type="integer") )
@CollectionOfElements
+ @Sort(type = SortType.NATURAL)
@Type(type = "float")
- private Map<Integer, Float> values = new HashMap<Integer, Float>();
+ private SortedMap<Integer, Float> values = new TreeMap<Integer, Float>();
public Integer getId() {
return id;
@@ -36,7 +42,7 @@
return values;
}
- public void setValues(Map<Integer, Float> values) {
+ public void setValues(SortedMap<Integer, Float> values) {
this.values = values;
}
}
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java 2008-06-09
15:50:47 UTC (rev 14753)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/collectionelement/TestCourse.java 2008-06-09
15:57:07 UTC (rev 14754)
@@ -1,15 +1,14 @@
//$Id$
package org.hibernate.test.annotations.collectionelement;
-import javax.persistence.Id;
-import javax.persistence.Table;
import javax.persistence.Embedded;
-import javax.persistence.GenerationType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
-import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.FilterDef;
+import org.hibernate.annotations.ParamDef;
/**
* @author Emmanuel Bernard